Less than two days from patch to hack: anatomy of a WordPress attack
The challenge: find out how the site was hacked and clean it up
The client came to us with a typical complaint: the hosting sent a malware alert, and an unfamiliar verified owner appeared in Google Search Console. A manufacturing company's website on WordPress, about twenty plugins, steady traffic from search. Web server logs had been turned on literally at the moment the client contacted us, so there was no request history. We had to figure out how the attacker got in and what they managed to do, clean out every last file and close the entry point, without breaking the working site.
How it all started
The client's three observations at the time they contacted us:
- 1The hosting antivirus found a file in the plugins folder named something like "system-monitor" with a random string of characters at the end.
- 2In the file manager, several folders had today's modification date, even though nobody had touched anything.
- 3Someone else appeared as an owner in Google Search Console, verified through an HTML file in the site root.
The entry point: not a plugin, but the core itself
The first hypothesis was obvious: a vulnerable plugin. The site had a file manager plugin known for a critical vulnerability in the past, and it looked like the main suspect: the site root had service folders that only this plugin creates.
The hypothesis turned out to be wrong. The installed version was newer than the vulnerable one, and the traces of the file manager's activity dated to after the first rogue administrator appeared. It was a tool for holding on to the site, not the way in.
The real entry point turned out to be the WordPress core. A vulnerability that was fresh at the time, CVE-2026-63030 (the campaign was named wp2shell), combines route confusion in the REST API with SQL injection in the post query parameter. Exploiting it needs neither authentication nor any user action: the attacker directly creates an administrator and uploads code.
Timeline of the takeover
From then on, the site lived a life of its own for more than a week. The reconstructed picture:
- July 19Two administrators are created with names resembling service accounts, counting on the owner taking them for system ones
- July 19-21Three more administrators from other tools: judging by the email domains in their profiles, several different groups found and took over the site
- July 21Two fake plugins are deployed in the plugins folder: a web shell for running commands and a file manager for uploading files
- July 22A must-use plugin appears (WordPress always loads these and doesn't show them in the regular list), plus another shell disguised as a caching plugin
- July 25-26New administrators with names like "administrator" followed by numbers, and shells spreading through the image folders
- July 27A mass change of modification times on hundreds of files, and someone else's ownership verified in Search Console
Three tricks worth knowing
1. Forged file modification dates
The nastiest surprise. The malicious files had dates from 2022-2024, so they looked old, long-standing and therefore harmless. In fact, all this code appeared within a single week: the attacker mass-set arbitrary modification times on files, a simple operation available to anyone who can run commands.
| What we found | Date on the file | Actually |
|---|---|---|
| Web shell disguised as a plugin | January 2024 | this week |
| Folders with spam data | November 2022 | this week |
2. A malicious .htaccess that keeps out competitors
The site root had a rewritten server configuration file with unusual logic: it denied execution of all PHP files except a short whitelist. The list included WordPress system files and about fifteen unfamiliar names.
# Outline of the malicious .htaccess (not the literal code) # PHP execution is denied to everyone... <FilesMatch "\.phpquot;> Deny from all </FilesMatch> # ...except system files and the first group's backdoors <FilesMatch "^(index|wp-login|defaults|mah|networks|...)\.phpquot;> Allow from all </FilesMatch>
In other words, the first group to take over the site locked out everyone else, leaving only its own backdoors working. A side effect: WordPress scheduled tasks stopped running on the site. The owner didn't notice.
3. A "Security Patch" plugin closing the very same hole
The most elegant find. The must-use plugins folder had a file presenting itself as "Security Patch: REST API hardening". And it really did block access to the vulnerable route, for everyone except those who know a secret header with a password.
What it was all for
Not destruction. The site was turned into a tool for someone else's SEO.
Sees the company's normal website, nothing suspicious
Gets spam pages targeting someone else's commercial queries
- Code was stitched into the site's main file that loaded content from an external server. It checked who was visiting and served spam only to search engine bots, while ordinary visitors saw the normal site.
- The root held about a dozen doorway files generating pages for someone else's commercial queries. By the time of the investigation, Googlebot and AI service crawlers were already actively crawling them: the spam had made it into the index.
- Additional entry points were planted in image folders and inside legitimate plugins. Their folders had plausible names, like cloudflare, nextjs and jquery3, impossible to tell from the real thing at a glance.
The damage here is to reputation and search: someone else's pages in the index, a risk of search engine penalties, and a rogue owner verified in Search Console.
What helped restore everything
The main investigation tool turned out to be a git repository, a version control system we had set up ourselves a few months before the incident, simply to make development easier.
Since file dates couldn't be trusted and there were no logs, the only reliable reference was "the state of the site at the last commit". Comparing against it gave a complete answer: which files were changed, which were added and what the originals looked like. More than that, it disproved the initial theory. Judging by the dates, the site seemed to have been infected since 2022; the comparison with the repository showed that at the time of the commit the site was completely clean, and everything happened within one week.
How we cleaned up and secured the WordPress site
- Collected evidence before making any changes: an archive of the malicious files and a database dump, needed both for the investigation and in case anything went wrong
- Removed the ten rogue administrators first: through the admin panel, an attacker can upload everything again in a minute
- Isolated the malicious code: not deleted but moved to quarantine outside the public folder, a reversible operation that preserves the evidence
- Restored modified files from clean versions
- Updated the WordPress core to the patched version: until this step, the site stayed vulnerable and could be hacked again at any moment
- Updated plugins and deleted unused ones: an inactive plugin is still executable code reachable by a direct link
- Changed the secret keys in the configuration to log everyone out, including the attacker
- Blocked PHP execution in the upload and image folders: those hold files from users, and executable code has no business there
- Set up a "gone for good" response (code 410) for spam pages that got into the index: search engines drop them faster that way than with a regular 404 error
- Revoked the rogue access in Search Console manually: deleting the verification file does not revoke ownership that is already verified
- Fixed the styling that broke after the plugin update: the needed styles had once been written straight into the plugin files, and the update wiped them. We moved the changes into the theme, where they survive updates, and along the way found and fixed a bug that had kept some styles from applying on mobile devices for years
The result: the site is clean and the entry point is closed
The site is fully cleaned and closed: ten rogue administrators removed, about forty malicious objects sent to quarantine, the core and plugins updated, and the spam pages are dropping out of search. The main investigation tool was a git repository we had set up ourselves a few months before the incident to make development easier: comparing against it let us check every file and prove the infection lasted a week, not years. Details in the breakdown above.
Checklist: what to do with your site today
If the core hasn't been updated in several months, that is your main risk, bigger than any plugin. Here, less than two days passed from the vulnerability's publication to the hack.
You should know every administrator. Accounts with "service-like" names are counting on you to take them for system accounts.
WordPress always loads them and doesn't show them in the regular list, which makes them an ideal hiding place. Normally the folder is either empty or holds what you installed yourself.
WordPress's own tools do this with a single command, and it immediately shows any foreign files.
Delete them, don't just deactivate them: an inactive plugin is still executable code reachable by a direct link.
Not having them in this case cost the most valuable part of the picture: the exact vector of the first request.
Even for a site with no active development: during an incident, it becomes a reference you can check every file against.
What else we checked
The hosting handled this story correctly: the sites on one account were isolated from each other, so the hack of one didn't give access to its neighbors. This is worth checking when choosing hosting: on platforms without such isolation, one vulnerable site compromises all the others on the account.
We also checked separately whether the email sending credentials had leaked. They hadn't, for a pleasant reason: the site sent email through system tools that need no login or password. There was nothing to store.