By PHP Patch Assurance · Last updated: 2026-11-20 · Plain-text version
Incident response for a compromised PHP site is a sequence, and doing the steps out of order destroys the information the later steps need. Deleting the visible malware first feels productive and is the most common mistake: it erases the evidence of how the attacker got in, while leaving the access they kept for themselves. This is the order that works.
Take a full copy of the site as it stands — files, database, and the server logs — before changing anything. That copy is both your evidence and your last-resort rollback. If the site is actively harming visitors (drive-by downloads, phishing pages), put up a static maintenance page; otherwise leave the system running while you copy it. Then note the time you discovered the compromise: every log search below is anchored to it.
Rotate every credential the site touches: hosting account, database user, CMS admin accounts, FTP/SSH users, API keys, and the application's salts and keys (in WordPress, the salt block in wp-config.php — rotating it invalidates every existing session). Revoke active sessions where the platform allows it. Assume any credential that existed on the server is known to the attacker.
Work the access logs backwards from the first sign of compromise: the first request to a file that should not exist, the first POST to an upload endpoint, the first admin login from a strange address. The usual doors are an outdated plugin or theme, an end-of-life PHP branch with a known exploit — check yours against the lifecycle dates — a web shell dropped through an upload form, or plain stolen credentials. You are not done until the door is named; an unnamed door stays open.
Restore a backup from before the compromise window — verify the date against the logs, because a backup taken after the break-in faithfully restores the backdoor — or rebuild the site fresh and migrate the content. Do not file-by-file 'clean' a compromised site and trust it: persistence mechanisms hide in databases, cron entries, .htaccess files and legitimate-looking PHP. Before the rebuilt site takes traffic, close the door: updated PHP, updated components, composer audit clean (see the Composer guide), and the hardening checklist applied.
Run the health checks and the free scan, then monitor the access and error logs daily for at least a week. Re-infection attempts against a second, hidden backdoor are the norm, not the exception — a quiet week is the evidence the rebuild was clean. If user data was exposed, tell the affected users plainly what happened and what you changed; that obligation does not wait for the monitoring week to finish.
Check your site free Patch service
This guide pairs with the free scan.
No. The files you found are the ones the attacker did not mind you finding. Backdoors persist in places a file scan does not reach — database content, scheduled tasks, modified core files. Rebuild from a known-good state; it is faster than a second compromise.
Neither order works alone: restore a clean site onto an unpatched stack and it is compromised again through the same door, sometimes within hours. Patch the entry point, then restore, then verify — in that order.
Rebuild the application fresh — new core, new plugins from their official sources — and migrate only content (posts, media, database tables) after inspecting it. It is more work than a restore, and it is the only version of the site you can actually vouch for.