Hiding WordPress Malware in the muPlugins Directory to Avoid Detection
Sucuri researchers have recently spotted threat actors deploying WordPress malware in the muPlugins directory to evade security checks. In February, Sucuri issued a warning about the exploitation of WordPress muPlugins, which auto-load without activation, to maintain persistence and avoid 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."
The attackers used obfuscated PHP in muPlugins 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. They detailed two cases of malware hiding in the muPlugins directory, which use different methods to compromise WordPress sites. The malware included a fake update redirect (redirect.php), a webshell (index.php) for full site control, and a spam injector (custom-js-loader.php).
Attackers increasingly target the muPlugins 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: Fake Update Redirection
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: Remote Code Execution Webshell
The second malware is a Remote Code Execution Webshell in index.php that 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.
The Third Malware: JavaScript Injector
The third malware detected by Sucuri 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 muPlugins folder, harming the site’s reputation and user experience while manipulating traffic for malicious purposes.
Impacts of Malware Infections
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," concludes the report.
Prevention and Mitigation
"The repeated abuse of the muPlugins directory highlights the creativity and persistence of attackers in hiding malware deep within WordPress installations. Regular security monitoring, file integrity checks, and web application firewalls (WAFs) are essential in keeping such infections at bay," reads the report.