Hiding WordPress malware in the mu-plugins directory to avoid detection

Sucuri researchers spotted threat actors deploying WordPress malware in the mu-plugins directory to evade security checks.

In February, Sucuri warned of threat actors exploiting WordPress mu-plugins, which auto-load without activation, to maintain persistence and evade detection by hiding backdoors in the plugin directory.

“Unlike regular plugins, must-use plugins are automatically loaded on every page load, without needing activation or appearing in the standard plugin list. Attackers exploit this directory to maintain persistence and evade detection, as files placed here execute automatically and are not easily disabled from the WordPress admin panel.” states Sucuri. “This makes it an ideal location for backdoors, allowing attackers to execute malicious code stealthily.”

Attackers used obfuscated PHP in mu-plugins to execute hidden payloads from /wp-content/uploads/2024/12/index.txt, using the functions eval() to run arbitrary code stealthily.

The script constructs a URL, sends requests to an external server, fetches content via file_get_contents() or cURL, modifies robots.txt, checks response markers, and pings sitemaps. The researchers noted that the script can manipulate website behavior, evade detection, and facilitate redirections.

The experts detailed two cases of malware hiding in the mu-plugins directory, which use different methods to compromise WordPress sites.

Malware in the mu-plugins directory includes a fake update redirect (redirect.php), a webshell (index.php) for full site control, and a spam injector (custom-js-loader.php). These malware allow attackers to redirect users, execute arbitrary code, and inject spam, aligning with past findings on hidden backdoors in WordPress sites.

“The presence of this malware can be identified by most obvious signs. One prominent indicator is unusual behavior on the site, such as unauthorized redirections of users to external malicious websites. Additionally, suspicious files with uncommon or misleading names appear within the mu-plugins directory, often mimicking legitimate plugins.” reads the report published by Sucuri. “Website administrators may also notice elevated server resource usage with no clear explanation, along with unexpected file modifications or the inclusion of unauthorized code in critical directories.”

Attackers increasingly target the mu-plugins directory for persistence, as it auto-loads plugins without activation. This allows them to redirect traffic, maintain backdoor access, and inject spam for SEO manipulation, making it hard to detect and remove.

The first malware analyzed by Sucuri is a fake update redirection malware in redirect.php that selectively redirects visitors to a malicious site while avoiding bots and admins to evade detection. Disguised as a WordPress function, it tricks users into executing malicious code, leading to data theft, backdoors, and further infections, compromising site security.

The second malware is a Remote Code Execution Webshell. A sophisticated attack in index.php disguises itself as a plugin, using cURL to fetch and execute a remote PHP script. This allows attackers to inject new malware dynamically without altering the file, enabling persistent control and ongoing infections.

WordPress malware in the mu-plugins directory

The third malware detected by Sucurity is a JavaScript injector in custom-js-loader.php that replaces site images with explicit content and hijacks links to open malicious popups. It ensures persistence in the mu-plugins folder, harming the site’s reputation and user experience while manipulating traffic for malicious purposes.

The infections discovered by the researchers aim for monetization and persistence. Redirect malware harms reputation and traffic, the webshell enables full site takeover and data theft, and spam injection replaces images with explicit content while hijacking links. Impacts range from SEO spam to severe security breaches, stressing the need for strong security.

Attackers may have deployed the malware through vulnerable plugins/themes, compromised admin credentials, or poorly secured hosting, allowing attackers to upload and execute malicious files.

“The repeated abuse of the mu-plugins directory highlights the creativity and persistence of attackers in hiding malware deep within WordPress installations.” concludes the report. “Regular security monitoring, file integrity checks, and web application firewalls (WAFs) are essential in keeping such infections at bay.”

Follow me on Twitter: @securityaffairs and Facebook and Mastodon

Pierluigi Paganini

(SecurityAffairs – hacking, mu-plugins)