The backdoor I missed for 131 days
✕

The backdoor I missed for 131 days

Senior software engineer

On this page

A laptop showing a WordPress file listing with wp-helper.php and wp-worker highlighted, next to a counter reading 131

In October I found a backdoor in a WordPress site I run. The awkward part is that I’d already cleaned that server once, in July, after an earlier problem. I hardened the site, removed some plugins, rotated the secrets and rebuilt the containers, and I came away believing it was clean. The backdoor was already there when I did all that, and it stayed there for another three and a half months.

The site belongs to a non-profit. I look after the server, and a few volunteers write and publish articles on it. I’ll call it Harbour Herald, which isn’t its real name. This post is about how I found the backdoor, what the logs and timestamps could and couldn’t tell me, and why my July clean-up missed it. It’s also about what I’ve changed since, which turned out to be more about how I verify things than about any one setting.

Finding it

I wasn’t hunting for malware that evening. PHP had just published a critical security advisory: two bugs, CVE-2026-109618 and CVE-2026-109619, that let an unauthenticated attacker run code on the server. Apache with mod_php was named as the highest-risk setup, and that’s what the site runs. The fixed releases were 8.3.36 and 8.5.12. So I started where I’d normally start: reading through the site’s code for anything risky, patching PHP and WordPress on my local copy, and testing that before touching production.

I do most of this kind of work with Claude Code. It’s quick at reading a lot of code and logs, and it did a fair share of the PHP upgrade. Once production was next, we went through the server, and part of that was running WordPress’s own integrity check inside the container:

wp core verify-checksums

This downloads the official checksums for your WordPress version and compares your core files against them. It came back with two warnings:

Warning: File should not exist: wp-helper.php
Warning: File should not exist: wp-worker

wp-helper.php sounds like something WordPress would ship, and wp-worker sounds like a background job. Neither is part of WordPress. They looked normal to me, and the checksum check flagged them anyway.

There’s a detail here I only understood later, when I read WP-CLI’s source. Without the --include-root flag, verify-checksums doesn’t check every file in the WordPress root. It checks wp-admin/, wp-includes/, and root files whose names start with wp-. The attacker chose those names to blend in, and the names are why the default check caught them. If the dropper had been called shell.php, I’d only have seen it with:

wp core verify-checksums --include-root

It also only covers core. Nothing under wp-content is checked: no themes, no uploads, and no plugins (wp plugin verify-checksums --all handles plugins, but only those hosted on wordpress.org). A clean result means core matches. It doesn’t mean the site is clean.

What the two files did

wp-helper.php was a small PHP dropper. A request like /wp-helper.php?mirror=<some URL> made the server download whatever was at that URL and run it. That’s remote code execution as the web server user, for anyone who knew the path, with no login.

wp-worker was an 8.3 MB Linux binary, the XMRig Monero miner. When I found it, it wasn’t running, and the server had no connections to mining pools.

That second point is less reassuring than it sounds. In July I’d recreated the containers, so any process history from before then was gone. I can say the miner wasn’t running on 21 October. I can’t say it never ran.

Rebuilding the 131 days

What I had to work with was file timestamps, the web server log, and my own memory of the July clean-up. Put together, the timeline looks like this (UTC):

2026-06-12 01:44:44  a WP File Manager backup folder appears in uploads, owned by www-data
2026-06-12 01:45:28  wp-helper.php and wp-worker written to the WordPress root
2026-07-06 17:26     my clean-up: hardening, three plugins quarantined, .env rotated,
                     containers recreated. The two files are missed
2026-07-06 17:38     earliest surviving web log entry (the recreated container starts a new log)
2026-07-09 10:05     first request to wp-helper.php in the surviving logs
2026-10-21 17:38     last request to wp-helper.php
2026-10-21 20:41     found by the checksum check
2026-10-21 20:43     contained

Incident timeline: compromise on 12 June, the clean-up in July, discovery on 21 October, 131 days in total, alongside the Sentinel setup and the checksum output

The last request came three hours before I found it.

Counting the requests in the log was easy:

grep 'wp-helper.php' access.log | wc -l
# 1664

grep 'wp-helper.php' access.log | awk '{print $1}' | sort -u | wc -l
# 580

That’s 1,664 requests from 580 different addresses between July and October. Most of them got a 200 with the same 222-byte body.

It’s tempting to read that as the backdoor being shared or sold, but the numbers don’t support it. Automated scanners probe every server they find for known backdoor paths all the time, and one operator rotating through proxies or a botnet would also look like hundreds of addresses. The 200 doesn’t prove much either. It tells me the script was there and answered. It doesn’t tell me a payload was downloaded or anything ran. The access log doesn’t record what the server did after it replied, and the container where anything would have run had been recreated. What I can say is that the backdoor was reachable for the whole period and something kept checking it.

As for how it got in: the site used to have the WP File Manager plugin, which has a history of serious vulnerabilities. Its backup folder appeared 44 seconds before the dropper, created by the same user. That’s a strong correlation, and it’s my best guess. It isn’t proof. The plugin was gone by October, and the June logs went when the containers were recreated in July, so the request that actually exploited it no longer exists anywhere I can look. I treat WP File Manager as the suspected entry point, not the confirmed one.

Why my clean-up missed it

I recreated the containers in July and thought of that as starting fresh. But the WordPress files don’t live in the container. They’re on the host and mounted into it, which is normal for WordPress in Docker and exactly what you want when you need your content to survive an upgrade. Anything written into the WordPress root survives too. Recreating the container replaced the PHP runtime, kept both files exactly where they were, and threw away the only logs from the period when they were written.

Then I rotated the secrets in .env, on a server that still had a working backdoor. The new values were readable through the same script the next day. Rotating credentials on a machine you haven’t cleaned just gives the attacker a fresh copy.

What I never did was compare the files against something known to be good. I updated things, looked through the folders, and judged that they looked fine, which they did, because the files were named to look fine. After that, the only evidence I had that the site was healthy was that nothing had gone wrong: no complaints from the people writing for it, no alerts, nothing flagged. I treated quiet as clean. Nobody was watching, so the quiet didn’t tell me anything.

Containing it

Once I knew what the files were, I did things in an order that kept the evidence intact.

First, evidence. Before deleting or restarting anything, the two files went to a folder only root can read, with their permissions removed and their hashes and original timestamps recorded. Roughly:

mkdir /root/incident-YYYYMMDD
stat wp-helper.php wp-worker > /root/incident-YYYYMMDD/timestamps.txt
mv wp-helper.php wp-worker /root/incident-YYYYMMDD/
chmod 000 /root/incident-YYYYMMDD/wp-*
sha256sum /root/incident-YYYYMMDD/wp-* > /root/incident-YYYYMMDD/SHA256SUMS

I also copied the full web log out of the container. That one matters more than it looks: the log lives with the container, and July had already shown me what a recreate does to it. Before changing anything else, I took a database dump and copies of the compose files, the config and the core, plugin and theme files. I didn’t take a disk snapshot or capture memory. By that point the miner wasn’t running, but if it had been, a snapshot would have been worth having before I touched anything.

Then I checked that /wp-helper.php returned 404, and searched the database for the usual places an attacker leaves something behind: new administrator accounts, scripts injected into posts, odd scheduled tasks, must-use plugins. It came back clean: four accounts, all created between 2020 and 2023, and public registration switched off.

Then the patching: PHP 8.5.12, WordPress 7.1.3, and every plugin and theme updated, with the checksums verified afterwards. I want to be precise about what this was. I removed the two known files and brought everything up to date. I didn’t rebuild the WordPress install from a clean download, and removing what you’ve found plus updating doesn’t prove a compromised system is clean. The checksums say core and the wordpress.org plugins match. For the rest, I’m relying on the database search and on Sentinel, which I’ll come to, staying quiet since.

Restoring trust in the credentials

The dropper ran as the web server user inside the WordPress container, so I assumed the attacker could read everything that container could read, and worked through it piece by piece.

  • Database passwords were regenerated on the server by a script, never printed, and checked before switching over.
  • WordPress’s keys and salts were regenerated, which logs everyone out. While doing this I found that the keys in .env had never actually been passed to the container. Another assumption from July that didn’t hold.
  • The object storage key for media got a new secret, and I checked that the old one was rejected with a 403.

Some things can’t be rotated. The users table holds email addresses and password hashes, and an email address can’t be changed the way a key can. So that question is about exposure, not rotation. The accounts belong to the handful of volunteers who write for the site, everyone uses aliases rather than real names or personal addresses, and there’s no public registration. On that basis I judged the personal-data risk to be low.

Building Sentinel

The obvious gap was that nothing had been watching. The next day I built a small tool called Sentinel to fix that, and most of its design came straight out of the previous evening.

Sentinel on a Raspberry Pi connects every 8 hours over SSH with a forced command to the WordPress server, which runs read-only checks and returns JSON results

It runs somewhere else. It runs on a Raspberry Pi at home rather than on the server it’s watching. Anything on the server can be read or changed by whoever controls the server, including a monitor and its record of what normal looks like. Keeping the rules, the baseline and the history on another machine means an attacker on the server can’t quietly edit what “expected” means. Some checks don’t need the server’s cooperation at all: from the Pi, Sentinel checks that each site answers, TLS expiry, security headers, and which ports are open from outside.

The SSH key can do exactly one thing. The Pi’s key goes into the server’s authorized_keys with a forced command, so whatever the client asks for, the server runs one read-only collector script. No shell, no port forwarding, no agent forwarding, and only from the Pi’s address. If someone took over the Pi, they’d get a health report, not a way into production. This deserves its own post, because SSH forced commands are a neat trick.

The collector prints facts, and the Pi decides. The script on the server collects facts and prints them as JSON: file checksum results, processes, listening ports, accounts, keys, cron jobs, enabled services, and a summary of the last 24 hours of web and SSH logs. All the judgement happens on the Pi. Changing a threshold or adding a rule never means touching production, and I can test every rule against recorded JSON from real runs, including one that recreates this incident’s log pattern.

The checks come from what went wrong. It runs the checksum checks every time, flags any PHP file outside WordPress’s normal entry points that answers 200 as critical (exactly what this backdoor looked like in the log), looks for PHP in the uploads folder and for known miners and mining-pool connections, compares PHP, WordPress and plugin versions with the latest releases, and compares accounts, SSH keys, cron and services against a baseline.

It runs every eight hours. One run a day emails me a report. The other two only update a dashboard, unless they find something new, in which case I get a message. Eight hours means a dropper like this one would be found the same day rather than four months later. It also means anything that appears and disappears between runs is invisible, which is the cost of polling.

It handles its own noise. Each finding has a stable ID and is shown as NEW, OPEN or FIXED, so the daily email shows what changed rather than repeating everything. A fixed finding is watched for another day, and if it comes back it’s marked REGRESSED and shown first. A site that doesn’t answer is a critical finding in its own right, not a skipped check. False positives get fixed in the rules: an early version flagged WordPress’s own wp-load.php as an unknown PHP file, and it’s now on the allowlist. When I change something on purpose, like adding an SSH key, I accept the new baseline explicitly.

Each finding also has a button that opens a GitHub issue for a second tool, Forge, which works on the fix and opens a pull request for me to review. When Sentinel flagged an outdated PHP version, getting it fixed was a matter of opening the issue and reviewing the PR. Making a fix that easy to act on has mattered as much as finding the problem.

Why build it myself

Honestly, I didn’t know tools like Wazuh or osquery existed when I built Sentinel. Having read about them since, they do a lot of what Sentinel does, and some of it better: Wazuh’s file-integrity monitoring watches changes as they happen rather than every eight hours, for example. What’s different about Sentinel is that it’s small, has no agent on the server, works through a key that can only read, and was shaped around one specific failure I understand very well. It also feeds straight into the Forge loop I already use. I’m not claiming it’s the better choice for anyone else.

It helped me to place it next to the tools I’ve since read about. Uptime Kuma, which I already run at home, answers whether a site is up, how fast it responds and when its certificate expires. It would have shown Harbour Herald as healthy for the whole 131 days, because the site was up the entire time. osquery is the closest thing to Sentinel’s collector: it exposes a machine’s processes, users, cron jobs, ports and file hashes as SQL tables, but leaves the rules, scheduling and alerting to you or to other software. Wazuh is the full version: an agent on the server and a central manager that watches file changes and logs in real time, with thousands of rules, configuration checks and automatic responses. It would almost certainly have flagged the dropper within seconds of it being written. It’s also a lot more to run than a one-server setup and a Raspberry Pi comfortably hold. Sentinel sits between those. It has no agent, only a read-only script the server runs when asked. It polls every eight hours instead of watching live. And it knows about the things I actually run: WordPress checksums and admin accounts, Docker containers, the sites behind Caddy. On top of that it scans my own sites from outside for the usual OWASP problems, and it ranks vulnerable packages by whether they’re being exploited in the wild. It covers less than Wazuh and reacts more slowly. What I get in return is something small enough that I understand every check in it.

There are a few places where, for a setup like mine, I think Sentinel actually comes out ahead. The biggest is what happens if the monitoring itself is compromised. Wazuh’s agent runs as root on the server and takes configuration and response commands from its manager, so whoever controls the manager has a route into production. Sentinel’s key can run one read-only script and nothing else, so taking over the Pi gets you a health report. Second, Sentinel looks at the sites from the outside as well as the inside: it can tell me that a .env file is downloadable, or that a port answers from the internet, which an agent sitting on the server doesn’t see. Third, it already knows the things this incident was about. WordPress checksums, unexpected admin accounts and “an unknown PHP file answering 200” are built in, where with Wazuh I’d be writing and maintaining those rules myself. And the output suits one person looking after one server: a daily email that only shows what changed, fixes that are watched in case they come back, and a button that turns a finding into a pull request. None of that makes it a replacement for Wazuh in general. It just fits this job better.

What it can’t do

The collector runs on the server it’s checking. Someone with root on that server could change the script or fake its output, and Sentinel would believe it. Keeping the judgement and history off the box makes that harder to get away with, but doesn’t prevent it. Polling misses anything short-lived. And the baseline was taken the day after the incident, so it treats whatever was on the server that day as normal. If something had been hidden that the checks don’t look for, the baseline would have accepted it as expected.

What I got wrong

When I lay the 131 days out, I can see four different jobs, and I’d treated them as one.

Prevention. The WordPress root was writable by the web server, because that’s how WordPress lets you update plugins from the admin page. It also means any bug that lets someone write a file can put that file anywhere on the site. And an old file manager plugin was installed on a site that didn’t need one.

Detection. Nothing was watching. The backdoor answered more than 1,600 requests in a log that nobody read. I took the absence of complaints as a signal, when it only told me nobody had noticed anything.

Remediation. In July I did things that felt thorough: recreating containers, rotating secrets. I hadn’t thought about where the files actually lived, or about the order: rotating before cleaning made the new secrets readable straight away.

Verification. This is the one I’d most like back. I never checked the result against anything known to be good. The clean-up was finished when I’d done the steps, not when I’d shown the site was clean. A ten-second command would have shown me those two files in July.

That last one is what’s changed most. “Nobody has complained” doesn’t count as evidence for me any more. The server gets checked every eight hours whether or not anyone is looking, and when something turns up, it becomes an issue, then a pull request I review, rather than a note to deal with later. Keeping a system running and having evidence that it’s still secure turned out to be two different jobs, and for four months I was only doing the first.

If you look after a WordPress site, run this today:

wp core verify-checksums --include-root
wp plugin verify-checksums --all

It won’t catch everything, and the reasons are above. But it would have caught this one, in July.

I wish I’d done it in July.

There was one Docker lesson from the same review that didn’t fit here: publishing a container port can get past UFW.

⊞ Start