Skip to content
RCE Write-up Advanced

A Self-Healing WordPress Infection, and How I Cleaned It With Claude Code

A WordPress site was infected with a self-healing webshell hidden as a database drop-in, which redeployed malicious plugins and markers if any component was removed. An attacker could execute code, maintain persistence, and access sensitive data, though the text does not specify how initial access was gained.

Garvsanwariya Follow

Published on medium.com

Cybersecurity

Garvsanwariya, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

Context

A small healthcare practice on shared hosting ran a WordPress site that stored patient contact form submissions. Their host's malware scanner kept flagging the site, they kept cleaning it, and a day later it was infected again. The site was slow, threw intermittent PHP errors, and the paid security plugin reported green throughout.

The engagement ran from first scan to a verified-clean site in about four hours. The interesting part is not the webshell itself but the persistence design behind it: a WordPress database drop-in that watches a set of marker files and redeploys any component that disappears. Every previous cleanup removed the visible payloads and left the watcher in place, so the infection rebuilt itself on the next page load.

All identifying detail (domain, IP, hostnames, usernames, credentials) has been stripped from what follows.

Setup

The work was done in two phases with different access levels.

  1. External reconnaissance with WPScan, Nmap and cURL, no credentials.
  2. Interactive work over SSH on the hosting account, with Claude Code driving enumeration while the researcher read output and directed the next question.

The install was a standard WordPress site on shared hosting. Core was on the current version and every plugin was current or one minor release behind. WPScan's API returned zero unpatched CVEs across the entire plugin inventory, so on a patch-management rubric the site would have passed.

Finding it

The external pass started with WPScan against the target, Nmap for the service surface, and cURL for manual endpoint pokes. The application layer looked fine. The infrastructure did not:

Text
PORT     STATE SERVICE  VERSION21/tcp   open  ftp      ProFTPD80/tcp   open  http     LiteSpeed443/tcp  open  ssl/http LiteSpeed3306/tcp open  mysql    MariaDB 11.8.x

Port 3306 was reachable from the entire internet. A raw socket connection completed the MySQL handshake and returned the server version, protocol version, thread ID and auth plugin, which confirms a database server accepting connection attempts from any IP on a site that stores patient contact form submissions.

Two further signals stood out:

  • An unauthenticated GET /wp-json/wp/v2/users returned every account on the site, including the administrator's exact username.
  • Probing xmlrpc.php produced a PHP fatal error instead of an XML fault, meaning the site's WAF was crashing.

The fatal error leaked the full server path, the hosting account name and the PHP include paths. More usefully, it showed that a required file inside the security plugin's protect/logger/ directory was missing. The plugin still showed as active in wp-admin while doing nothing at all: something had gutted it.

At that point external testing stopped and SSH access was requested.

Exploitation

Step 1: sort the webroot by modification time

The first pass over SSH sorted the entire webroot by mtime. Almost everything was months old. A cluster of files had been written that same morning, across roughly a one-hour window:

Time (UTC) File
10:24 mu-plugins/.sd_smooth-importer-dot (6 bytes)
10:25 plugins/smooth-importer-dot/ created
10:29 wp-content/.sc_721f8bf2, wp-content/.kk_a198c726
10:30 wp-content/.rd_smooth-importer-dot
10:32 mu-plugins/.bt_smooth-importer-dot
10:33 wp-content/.htaccess rewritten
11:23 Two smooth-importer-dot.php payloads written

The client had run a host-side malware cleanup the day before, so this was not residue. It was a fresh deployment that happened while the engagement was being scoped.

Step 2: examine the drop-in

wp-content/db.php was 213 KB and 1,036 lines, starting with:

It was a ScAttacker-family webshell, version 4.3.24, installed as a WordPress database drop-in. That location matters more than the payload: wp-content/db.php is loaded by WordPress on every single request, before plugins, before the theme, before anything else. It is a legitimate WordPress feature intended for custom database layers, which makes it the best hiding place on an install, because it does not appear in the plugins list, cannot be deactivated from the admin, and is unknown to most site owners.

The file was obfuscated with a custom character-substitution cipher, but the function table decoded cleanly enough to read. Its capabilities were:

  • create directories
  • write and delete arbitrary files
  • unpack archives
  • execute SQL directly
  • fingerprint the PHP environment
  • beacon liveness to a C2 host
  • inject into theme files
  • drop replacement copies of the other components
  • rewrite file modification timestamps, specifically to defeat the sort-by-mtime check just performed

The timestamp-rewriting function had not been used on this deployment. That is luck, not skill.

Step 3: the fake plugin, twice

A directory smooth-importer-dot in plugins/ held a single 6.9 MB PHP file with a convincing plugin header: name, GitHub URI, description, semantic version, author, GPL licence. The giveaway sat underneath, a version marker matching the drop-in's:

Text
/* SCV:4.3.24 */

A 6.4 MB near-copy sat in mu-plugins/. Must-Use plugins load automatically on every request and cannot be deactivated from the WordPress admin: there is no toggle and no list entry, only file deletion. Both copies were set to read-only permissions, which defeats the naive cleanup path where a plugin tries to unlink the file and silently fails.

Step 4: the marker files and cron jobs

Five near-empty dotfiles were scattered around wp-content/ and mu-plugins/: .sc_, .kk_, .rd_, .bt_, .sd_, each suffixed with a deployment hash or the fake plugin's name. These formed the state machine. The drop-in checked them on load, and if a marker was missing it assumed that component had been cleaned and redeployed it.

The deployment hash in .sc_721f8bf2 is the key detail. The host's scanner had previously removed a file under a different hash, and a different hash means a new deployment rather than a leftover. That confirmed the self-healing loop was live rather than theoretical.

In the database, wp_options held five scheduled cron events belonging to no legitimate plugin: a guard task, a payload fetcher, and three with randomised alphanumeric names.

Step 5: the hidden administrator

A user audit against wp_users found an administrator with an auto-generated username in a backup_<hex> pattern, registered a few weeks earlier, with an email address pointing back at the site's own domain. The client's team of three had become a team of four without anyone noticing, because the account never appeared in a REST API response and nobody had reviewed the Users screen closely.

Step 6: everything else on disk

  • wp-content/.htaccess had grown to 1,576 lines of injected php_value directives, against the three to five lines a legitimate one contains.
  • A 1.7 MB debug.log sat on disk with full server paths and error traces.
  • The broken WAF's loader file was still in the webroot, throwing a fatal error on requests that touched it.

Step 7: the kill order

Order is what defeated every previous attempt. Delete the fake plugin first and the drop-in notices the missing marker on the very next page load and writes it back. Delete the markers first and the same thing happens. Both the client and the host had been pulling leaves off a weed.

The drop-in has to go first, everything else second, because once the dropper is gone nothing is watching:

Bash
rm wp-content/db.phprm -rf wp-content/plugins/smooth-importer-dot/rm wp-content/mu-plugins/smooth-importer-dot.phprm wp-content/.sc_* wp-content/.kk_* wp-content/.rd_* \   wp-content/mu-plugins/.bt_* wp-content/mu-plugins/.sd_*rm wp-content/debug.log

Then the database side: the five attacker cron events unscheduled and the backdoor administrator deleted.

Then credentials, which people skip and should not. The attacker had held code execution for weeks and could read wp-config.php at will, so every secret on the box had to be treated as burned:

  • all eight WordPress security salts regenerated, which invalidates every active session including any the attacker held
  • every user password reset
  • database, SSH, FTP and hosting panel passwords rotated
  • 2FA enabled where the panel supported it

Root cause

The persistence design explains why every previous cleanup failed. A drop-in loaded on every request holds the state machine, and the marker files tell it which components are missing. Any cleanup that removes a payload without removing the drop-in is undone on the next request, and the drop-in's timestamp-rewriting function exists specifically to hide redeployments from mtime-based triage.

What is established is the exposure that made the box reachable and the defences that failed to stop or detect the intrusion:

  • MySQL on 3306 was open to the internet.
  • The REST API exposed every username, including the administrator's.
  • XML-RPC was fully enabled with system.multicall, which lets an attacker test hundreds of passwords in one HTTP request and sail past any login rate limit.
  • The security plugin's WAF was broken because a required file in protect/logger/ was missing, while the plugin still reported active in wp-admin.
  • The backdoor administrator account never appeared in a REST API response, and nobody had reviewed the Users screen closely.

Impact

The drop-in gave the attacker code execution on every request, with the ability to write and delete arbitrary files, unpack archives, run SQL directly, inject into theme files, beacon to a C2 host and redeploy components. Because it could read wp-config.php, every credential on the account had to be considered compromised. The site stored patient contact form submissions, and the database was reachable directly from the internet.

The attacker had held code execution for weeks, and the infection survived at least one host-side cleanup.

Fix

The cleanup above was performed: drop-in first, then the fake plugin and MU-plugin copies, the marker files, debug.log, the five cron events and the backdoor administrator, followed by full credential rotation and salt regeneration.

Hardening went in afterwards, because cleanup restores the site but does not fix why it was reachable:

  • XML-RPC blocked at .htaccess.
  • REST API user enumeration blocked via a small MU-plugin that removes the /wp/v2/users endpoint for unauthenticated requests, which now returns 404.
  • Author enumeration blocked, since /?author=1 redirecting to /author/username/ is the same leak through a different door.
  • PHP execution denied inside wp-content/uploads/, so a file placed there is inert.

Variants to test

  1. Check for a wp-content/db.php drop-in on any WordPress incident. A positive result is a file that is not part of a known custom database layer, especially one with an unusual size or an obfuscated function table.
  2. Look for marker dotfiles in wp-content/ and mu-plugins/. A positive result is a set of near-empty files with short prefixes and hash or plugin-name suffixes, written in a tight time window.
  3. Compare deployment hashes across cleanups. A marker hash that differs from the one a previous scanner removed indicates a fresh deployment rather than residue.
  4. Audit wp_options for cron events with no owning plugin. A positive result is guard or fetcher tasks plus randomised alphanumeric names.
  5. Review wp_users for backup_<hex> style accounts with auto-generated names and email addresses on the site's own domain, and cross-check against REST API output, since a hidden account may not appear there.
  6. Check .htaccess line counts in wp-content/. A positive result is hundreds or thousands of injected php_value directives where three to five lines are expected.
  7. Probe xmlrpc.php and watch for PHP fatal errors rather than XML faults, which points at a broken WAF and may leak paths and account names.
  8. Request /wp-json/wp/v2/users and /?author=1 unauthenticated. A positive result is a full user list or a redirect to /author/username/.
  9. Scan for MySQL on 3306 from outside. A positive result is a completed handshake returning version, protocol version, thread ID and auth plugin.
  10. Check whether payload files are read-only. A positive result explains why plugin-based cleanup silently fails, and means deletion must be done with the right permissions and in the right order.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 20 min read.

What happened, in plain words

A small healthcare practice runs a website built with WordPress, a popular tool for building and managing websites. People fill in a contact form on that site, and the practice stores those messages, which include patient details. The site lives on shared hosting: a server owned by a hosting company where many customers' websites sit side by side.

The practice kept getting the same message from their hosting company's malware scanner, a program that looks for malicious files on a server. The scanner said the site was infected. They cleaned it. A day later it was infected again. The site was slow, it sometimes showed PHP errors (PHP is the programming language WordPress is written in, and an error means something in the code failed), and the security plugin they paid for kept showing a green light, as if all was well.

A researcher was brought in. From the first scan to a site confirmed clean took about four hours. The interesting part is not the malicious file itself but the way it was built to survive: a hidden file that WordPress loads on every single page view, which watches a set of small marker files and puts back anything that has been deleted. Every earlier cleanup removed the visible bad files and left the watcher in place, so the infection rebuilt itself the next time anyone visited the site.

All identifying details (domain, IP address, hostnames, usernames, passwords) have been removed from what follows.

How the work was set up

The work happened in two phases, with different levels of access.

  1. Looking at the site from the outside, with no login: using three tools, WPScan (which checks a WordPress site for known weaknesses), Nmap (which lists which network services a server offers) and cURL (a command-line tool for sending web requests by hand).
  2. Working interactively over SSH. SSH is a way to log in to a server's command line from your own computer, like a remote keyboard and screen. On the server, a tool called Claude Code ran the searching and listing commands while the researcher read the output and decided what to ask next.

The site was a standard WordPress install on shared hosting. The core of WordPress (the main program, as opposed to add-ons) was on the current version, and every plugin (an add-on that adds features) was current or one minor release behind. WPScan's API returned zero unpatched CVEs across the whole plugin inventory. An API is a way for one program to ask another for information over the network; a CVE is a public catalogue entry for a known security flaw. So if you were grading the site on how up to date its software was, it would have passed.

Finding it

The outside pass started with WPScan against the target, Nmap for the service surface, and cURL for manual endpoint pokes. An endpoint is a specific address on a server that answers a particular kind of request, like a counter in a building that only deals with one type of form. The website software looked fine. The underlying server did not:

Text
PORT     STATE SERVICE  VERSION21/tcp   open  ftp      ProFTPD80/tcp   open  http     LiteSpeed443/tcp  open  ssl/http LiteSpeed3306/tcp open  mysql    MariaDB 11.8.x

This is Nmap's output, one line per network port. A port is a numbered door on a server; different services listen on different doors. Reading it line by line:

  • 21/tcp open ftp ProFTPD: door 21 is open and answers FTP, an old protocol for transferring files, here served by software called ProFTPD.
  • 80/tcp open http LiteSpeed: door 80 is open and serves ordinary web pages (http), handled by web server software called LiteSpeed.
  • 443/tcp open ssl/http LiteSpeed: door 443 is open and serves encrypted web pages (https), also LiteSpeed.
  • 3306/tcp open mysql MariaDB 11.8.x: door 3306 is open and answers MySQL, the language databases speak. The database software is MariaDB, version 11.8.x.

Port 3306 was reachable from the entire internet. The researcher confirmed it with a raw socket, meaning a direct connection made without any special client software. The MySQL handshake completed and returned the server version, protocol version, thread ID and auth plugin. A handshake is the opening exchange where two programs introduce themselves; an auth plugin is the piece of software that decides how a database checks who is logging in. In plain terms: a database server was accepting connection attempts from any computer on earth, on a site that stores patient contact form submissions.

Two other things stood out:

  • An unauthenticated GET /wp-json/wp/v2/users returned every account on the site, including the administrator's exact username. Unauthenticated means no login was needed. GET is the type of web request used to fetch something. The address is part of WordPress's REST API, a feature that lets programs talk to the site; this particular address is meant to list users. It should not answer strangers, but it did.
  • Probing xmlrpc.php produced a PHP fatal error instead of an XML fault, meaning the site's WAF was crashing. xmlrpc.php is a WordPress file that lets other programs perform actions on the site remotely. XML is a text format for structured data, and a fault is the polite error message that file normally returns when something is wrong. A WAF, or web application firewall, is a filter that sits in front of a site and blocks suspicious requests, like a bouncer at a door. Here the bouncer had collapsed.

The fatal error leaked the full server path, the hosting account name and the PHP include paths. A path is the folder route to a file on the server, for example where the site's files physically live. More usefully, it showed that a required file inside the security plugin's protect/logger/ directory was missing. The plugin still showed as active in wp-admin, the site's own control panel, while doing nothing at all: something had gutted it.

At that point external testing stopped and SSH access was requested.

What was on the server

Step 1: sort the webroot by modification time

The first pass over SSH sorted the entire webroot by mtime. The webroot is the top folder that holds all of a website's files. Mtime means modification time, the date and time a file was last changed. Almost everything was months old. A cluster of files had been written that same morning, across roughly a one-hour window:

Time (UTC) File
10:24 mu-plugins/.sd_smooth-importer-dot (6 bytes)
10:25 plugins/smooth-importer-dot/ created
10:29 wp-content/.sc_721f8bf2, wp-content/.kk_a198c726
10:30 wp-content/.rd_smooth-importer-dot
10:32 mu-plugins/.bt_smooth-importer-dot
10:33 wp-content/.htaccess rewritten
11:23 Two smooth-importer-dot.php payloads written

UTC is a common world time standard, so times can be compared across countries. A byte is a unit of file size; 6 bytes is essentially an empty file. A payload is the part of an attack that actually does the damage. The client had run a host-side malware cleanup the day before, so this was not residue. It was a fresh deployment that happened while the engagement was being scoped.

Step 2: examine the drop-in

wp-content/db.php was 213 KB and 1,036 lines, starting with:

That single line is the opening tag that tells the server "PHP code starts here". It is how every PHP file begins, which is exactly why it is unremarkable at a glance.

It was a ScAttacker-family webshell, version 4.3.24, installed as a WordPress database drop-in. A webshell is a piece of code placed on a server that lets an outsider run commands on it through the web. A family is a group of malicious files that share code and behaviour. A drop-in is a WordPress feature: a file with a special name that WordPress loads automatically, without being asked, on every request. That location matters more than the payload: wp-content/db.php is loaded by WordPress on every single request, before plugins, before the theme, before anything else. It is a legitimate WordPress feature intended for custom database layers, which makes it the best hiding place on an install, because it does not appear in the plugins list, cannot be deactivated from the admin, and is unknown to most site owners.

The file was obfuscated with a custom character-substitution cipher. Obfuscated means deliberately made hard to read; a substitution cipher swaps each character for another according to a rule, so the code looks like nonsense until you reverse the rule. The function table decoded cleanly enough to read. A function table is a list of the actions the code can perform. Its capabilities were:

  • create directories
  • write and delete arbitrary files
  • unpack archives
  • execute SQL directly
  • fingerprint the PHP environment
  • beacon liveness to a C2 host
  • inject into theme files
  • drop replacement copies of the other components
  • rewrite file modification timestamps, specifically to defeat the sort-by-mtime check just performed

In plain words: it could make folders; create and remove any file it liked; open compressed bundles of files; run SQL, the language used to query databases, directly; fingerprint the PHP environment, meaning record details about the server's setup; beacon liveness to a C2 host, meaning regularly send a "still here" signal to a command-and-control server run by the attacker; plant code inside the site's theme (the part that controls how the site looks); put back fresh copies of the other malicious pieces; and change files' modification times so they no longer look recent.

The timestamp-rewriting function had not been used on this deployment. That is luck, not skill.

Step 3: the fake plugin, twice

A directory smooth-importer-dot in plugins/ held a single 6.9 MB PHP file with a convincing plugin header: name, GitHub URI, description, semantic version, author, GPL licence. A plugin header is the comment block at the top of a plugin file that WordPress reads to show the plugin in its list. GitHub URI is a web address pointing at a code repository; semantic version is a numbering scheme like 1.2.3; GPL is a common open-source software licence. The giveaway sat underneath, a version marker matching the drop-in's:

Text
/* SCV:4.3.24 */

This is a comment in the file, invisible on the website, carrying the same version number as the hidden drop-in.

A 6.4 MB near-copy sat in mu-plugins/. Must-Use plugins load automatically on every request and cannot be deactivated from the WordPress admin: there is no toggle and no list entry, only file deletion. Both copies were set to read-only permissions, which defeats the naive cleanup path where a plugin tries to unlink the file and silently fails. Permissions are the rules about who may read, change or delete a file; read-only means even the site itself cannot remove it.

Step 4: the marker files and cron jobs

Five near-empty dotfiles were scattered around wp-content/ and mu-plugins/: .sc_, .kk_, .rd_, .bt_, .sd_, each suffixed with a deployment hash or the fake plugin's name. A dotfile is a file whose name starts with a dot, which many tools hide from ordinary listings. A hash is a short string of characters produced from other data, used here as a label for one particular deployment. These formed the state machine: a set of small files whose presence or absence tells a program what to do next. The drop-in checked them on load, and if a marker was missing it assumed that component had been cleaned and redeployed it.

The deployment hash in .sc_721f8bf2 is the key detail. The host's scanner had previously removed a file under a different hash, and a different hash means a new deployment rather than a leftover. That confirmed the self-healing loop was live rather than theoretical.

In the database, wp_options held five scheduled cron events belonging to no legitimate plugin: a guard task, a payload fetcher, and three with randomised alphanumeric names. wp_options is a WordPress database table that stores settings. A cron event is a task scheduled to run automatically at set times. A guard task watches over something; a payload fetcher downloads the next piece of malicious code.

Step 5: the hidden administrator

A user audit against wp_users found an administrator with an auto-generated username in a backup_<hex> pattern, registered a few weeks earlier, with an email address pointing back at the site's own domain. wp_users is the database table holding accounts; hex means hexadecimal, a way of writing numbers using 0 to 9 and A to F. An administrator account can do anything on the site. The client's team of three had become a team of four without anyone noticing, because the account never appeared in a REST API response and nobody had reviewed the Users screen closely.

Step 6: everything else on disk

  • wp-content/.htaccess had grown to 1,576 lines of injected php_value directives, against the three to five lines a legitimate one contains. .htaccess is a configuration file that tells the web server how to behave; php_value lines set PHP settings. Thousands of extra lines are a strong sign of tampering.
  • A 1.7 MB debug.log sat on disk with full server paths and error traces. A log is a running record of events; a debug log records errors in detail, which is useful to an attacker reading it.
  • The broken WAF's loader file was still in the webroot, throwing a fatal error on requests that touched it.

Step 7: the kill order

Order is what defeated every previous attempt. Delete the fake plugin first and the drop-in notices the missing marker on the very next page load and writes it back. Delete the markers first and the same thing happens. Both the client and the host had been pulling leaves off a weed.

The drop-in has to go first, everything else second, because once the dropper is gone nothing is watching:

Bash
rm wp-content/db.phprm -rf wp-content/plugins/smooth-importer-dot/rm wp-content/mu-plugins/smooth-importer-dot.phprm wp-content/.sc_* wp-content/.kk_* wp-content/.rd_* \   wp-content/mu-plugins/.bt_* wp-content/mu-plugins/.sd_*rm wp-content/debug.log

This is a list of shell commands, the instructions you type at a server's command line. Read line by line:

  • rm wp-content/db.php deletes the drop-in. This is the one that must go first.
  • rm -rf wp-content/plugins/smooth-importer-dot/ deletes the fake plugin folder and everything inside it. The -r means recursive (go into folders) and -f means force (do not ask for confirmation).
  • rm wp-content/mu-plugins/smooth-importer-dot.php deletes the second copy of the fake plugin.
  • rm wp-content/.sc_* wp-content/.kk_* wp-content/.rd_* \ deletes the marker files whose names begin with those prefixes. The backslash at the end means the command continues on the next line.
  • wp-content/mu-plugins/.bt_* wp-content/mu-plugins/.sd_* finishes the marker list.
  • rm wp-content/debug.log deletes the log file that was leaking server details.

Then the database side: the five attacker cron events unscheduled and the backdoor administrator deleted. A backdoor is a way in that the attacker leaves behind for later.

Then credentials, which people skip and should not. Credentials are the usernames and passwords that prove who you are. The attacker had held code execution for weeks and could read wp-config.php at will, so every secret on the box had to be treated as burned. wp-config.php is the WordPress settings file that holds the database password and other secrets. The steps taken:

  • all eight WordPress security salts regenerated, which invalidates every active session including any the attacker held. A salt is a random string mixed into password and cookie calculations; a session is a logged-in state kept alive by a cookie, a small piece of data your browser stores for a site. Changing the salts makes every existing cookie useless.
  • every user password reset
  • database, SSH, FTP and hosting panel passwords rotated. Rotated means changed. FTP is the file transfer protocol seen on port 21 earlier; the hosting panel is the web page where the hosting account is managed.
  • 2FA enabled where the panel supported it. 2FA, two-factor authentication, asks for a second proof beyond the password, such as a code from a phone.

Why it kept coming back

The persistence design explains why every previous cleanup failed. A drop-in loaded on every request holds the state machine, and the marker files tell it which components are missing. Any cleanup that removes a payload without removing the drop-in is undone on the next request, and the drop-in's timestamp-rewriting function exists specifically to hide redeployments from mtime-based triage.

What is established is the exposure that made the box reachable and the defences that failed to stop or detect the intrusion:

  • MySQL on 3306 was open to the internet.
  • The REST API exposed every username, including the administrator's.
  • XML-RPC was fully enabled with system.multicall, which lets an attacker test hundreds of passwords in one HTTP request and sail past any login rate limit. XML-RPC is the remote-control feature mentioned earlier; system.multicall lets one request carry many actions at once. A rate limit is a cap on how many attempts are allowed in a period.
  • The security plugin's WAF was broken because a required file in protect/logger/ was missing, while the plugin still reported active in wp-admin.
  • The backdoor administrator account never appeared in a REST API response, and nobody had reviewed the Users screen closely.

What the attacker could do

The drop-in gave the attacker code execution on every request, with the ability to write and delete arbitrary files, unpack archives, run SQL directly, inject into theme files, beacon to a C2 host and redeploy components. Because it could read wp-config.php, every credential on the account had to be considered compromised. The site stored patient contact form submissions, and the database was reachable directly from the internet.

The attacker had held code execution for weeks, and the infection survived at least one host-side cleanup.

The fix

The cleanup above was performed: drop-in first, then the fake plugin and MU-plugin copies, the marker files, debug.log, the five cron events and the backdoor administrator, followed by full credential rotation and salt regeneration.

Hardening went in afterwards, because cleanup restores the site but does not fix why it was reachable. Hardening means closing the easy ways in so the next attempt costs more:

  • XML-RPC blocked at .htaccess.
  • REST API user enumeration blocked via a small MU-plugin that removes the /wp/v2/users endpoint for unauthenticated requests, which now returns 404. A 404 is the standard "not found" answer a web server gives.
  • Author enumeration blocked, since /?author=1 redirecting to /author/username/ is the same leak through a different door. Enumeration means listing things one by one; here, guessing author numbers to learn usernames.
  • PHP execution denied inside wp-content/uploads/, so a file placed there is inert. Inert means it sits there but cannot run.

Checks worth repeating

  1. Check for a wp-content/db.php drop-in on any WordPress incident. A positive result is a file that is not part of a known custom database layer, especially one with an unusual size or an obfuscated function table.
  2. Look for marker dotfiles in wp-content/ and mu-plugins/. A positive result is a set of near-empty files with short prefixes and hash or plugin-name suffixes, written in a tight time window.
  3. Compare deployment hashes across cleanups. A marker hash that differs from the one a previous scanner removed indicates a fresh deployment rather than residue.
  4. Audit wp_options for cron events with no owning plugin. A positive result is guard or fetcher tasks plus randomised alphanumeric names.
  5. Review wp_users for backup_<hex> style accounts with auto-generated names and email addresses on the site's own domain, and cross-check against REST API output, since a hidden account may not appear there.
  6. Check .htaccess line counts in wp-content/. A positive result is hundreds or thousands of injected php_value directives where three to five lines are expected.
  7. Probe xmlrpc.php and watch for PHP fatal errors rather than XML faults, which points at a broken WAF and may leak paths and account names.
  8. Request /wp-json/wp/v2/users and /?author=1 unauthenticated. A positive result is a full user list or a redirect to /author/username/.
  9. Scan for MySQL on 3306 from outside. A positive result is a completed handshake returning version, protocol version, thread ID and auth plugin.
  10. Check whether payload files are read-only. A positive result explains why plugin-based cleanup silently fails, and means deletion must be done with the right permissions and in the right order.

Glossary

  • 2FA (two-factor authentication): a login that asks for a second proof beyond the password, such as a code from a phone.
  • API: a way for one program to ask another for information or ask it to do something over a network.
  • Auth plugin: the piece of database software that decides how logins are checked.
  • Backdoor: a way into a system that an attacker leaves behind for later use.
  • Beacon: a regular signal sent from an infected machine to an attacker's server to say it is still there.
  • Byte: a unit of file size; 6 bytes is essentially an empty file.
  • C2 (command and control): the server an attacker uses to send instructions to and receive signals from infected machines.
  • Cookie: a small piece of data a website stores in your browser, often used to keep you logged in.
  • Credentials: the usernames and passwords that prove who you are.
  • Cron event: a task scheduled to run automatically at set times.
  • cURL: a command-line tool for sending web requests by hand.
  • CVE: a public catalogue entry for a known security flaw.
  • Debug log: a file recording errors in detail, useful to an attacker who can read it.
  • Directory: a folder on a computer.
  • Dotfile: a file whose name starts with a dot, often hidden from ordinary listings.
  • Drop-in: a WordPress feature where a file with a special name is loaded automatically on every request.
  • Endpoint: a specific address on a server that answers a particular kind of request.
  • Enumeration: listing things one by one, often by guessing numbers or names.
  • FTP: an old protocol for transferring files between computers.
  • Function table: a list of the actions a piece of code can perform.
  • GET: the type of web request used to fetch something.
  • GitHub URI: a web address pointing at a code repository.
  • GPL: a common open-source software licence.
  • Handshake: the opening exchange where two programs introduce themselves.
  • Hardening: closing easy ways in so a future attack costs more.
  • Hash: a short string of characters produced from other data, used as a label.
  • Hex (hexadecimal): a way of writing numbers using 0 to 9 and A to F.
  • Hosting panel: the web page where a hosting account is managed.
  • .htaccess: a configuration file that tells a web server how to behave.
  • HTTP / HTTPS: the protocols browsers use to fetch web pages; HTTPS is the encrypted version.
  • Inert: present but unable to run.
  • Log: a running record of events.
  • Malware scanner: a program that looks for malicious files on a server.
  • MariaDB / MySQL: database software and the language used to query it.
  • Marker file: a small file whose presence or absence tells a program what to do.
  • Mtime: modification time, when a file was last changed.
  • MU-plugin (Must-Use plugin): a WordPress plugin that loads automatically and cannot be switched off from the admin.
  • Nmap: a tool that lists which network services a server offers.
  • Obfuscation: deliberately making code hard to read.
  • Path: the folder route to a file on a server.
  • Payload: the part of an attack that actually does the damage.
  • Permissions: the rules about who may read, change or delete a file.
  • PHP: the programming language WordPress is written in.
  • Plugin: an add-on that adds features to WordPress.
  • Port: a numbered door on a server; different services listen on different doors.
  • Rate limit: a cap on how many attempts are allowed in a period.
  • REST API: a web interface that lets programs talk to a site.
  • Root cause: the underlying reason something happens.
  • Salt: a random string mixed into password and cookie calculations.
  • Semantic version: a numbering scheme like 1.2.3.
  • Session: a logged-in state kept alive by a cookie.
  • Shared hosting: a server owned by a hosting company where many customers' websites sit side by side.
  • Shell / command line: the text interface where you type instructions to a server.
  • SQL: the language used to query databases.
  • SSH: a way to log in to a server's command line from your own computer.
  • State machine: a set of small files or states whose presence tells a program what to do next.
  • Substitution cipher: a rule that swaps each character for another, making text look like nonsense.
  • Theme: the part of a WordPress site that controls how it looks.
  • Triage: sorting findings by importance to decide what to look at first.
  • Unauthenticated: done without logging in.
  • UTC: a common world time standard.
  • WAF (web application firewall): a filter in front of a site that blocks suspicious requests.
  • Webroot: the top folder that holds all of a website's files.
  • Webshell: code placed on a server that lets an outsider run commands through the web.
  • WordPress: a popular tool for building and managing websites.
  • WPScan: a tool that checks a WordPress site for known weaknesses.
  • XML: a text format for structured data.
  • XML-RPC: a WordPress feature that lets other programs perform actions on the site remotely.
  • 404: the standard "not found" answer a web server gives.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.