A WordPress site has just been compromised. Wordfence is screaming, the marketing director is on Slack, and the customer who reported “weird redirects” is on hold. The first 60 minutes determine whether this becomes a contained incident with a clear recovery path or a multi-day rebuild with regulator notifications attached. The playbook below is the one to execute, in order, with the decisions that cannot be made on the fly and the evidence that cannot be lost.
What’s happening
A WordPress compromise typically presents in one of four shapes: defaced homepage, spam injection on every page, malware payload served to visitors, or admin account takeover with no visible site change. The response playbook is the same for all four — the goal in the first hour is not to fix the site, it is to contain the attacker, preserve evidence, and produce a defensible artifact of what happened.
The wrong moves in the first 60 minutes that operators reach for:
- Deleting the malicious files immediately (destroys evidence).
- Restoring from backup immediately (might restore the same vulnerability and reinfect within hours).
- Changing all passwords immediately (good idea but does not contain attacker who has a session cookie or a backdoor file).
- Posting about the incident publicly (legal will want a word).
The right sequence: contain, preserve, assess, then decide on recovery path.
How to verify
Decide whether you have an incident. Sometimes “site is acting weird” is a plugin conflict, not a compromise. Quick verification:
# Check for unexpected admin users
wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
# Check for recent file modifications
find /var/www/html -name "*.php" -mtime -7 -ls | head -20
# Check core file integrity
wp core verify-checksums
wp plugin verify-checksums --all
# Check for known shell signatures in PHP files
grep -rE 'eval\(base64_decode|gzinflate\(base64|str_rot13|preg_replace.*\/e' \
/var/www/html --include='*.php' 2>/dev/null | head
# Check for unexpected scheduled events
wp cron event list
If any of these return suspicious results — a new admin user nobody created, PHP files modified in wp-includes in the last week, a base64-encoded eval payload — you have a confirmed incident. Proceed to the 60-minute playbook.
The fix
The clock starts when you have confirmed compromise. The minute markers below are guidance, not strict — adjust based on what you find.
-
Minute 0-5: notify the incident channel. Get the team in one room (Slack channel, war room, whatever you have). Identify an incident commander, a comms lead, and a technical lead. The commander makes decisions, the comms lead handles outside communication including legal and the customer, the technical lead drives the playbook. One person can hold multiple roles on a small team, but the roles must be named — do not run an incident response by committee.
-
Minute 5-15: contain. This is the critical step that most operators skip in their rush to “fix.” Containment options, from least disruptive to most:
- WAF block on the site — Cloudflare custom rule that returns 403 for all traffic except your IP. Site goes offline to visitors but stays available to you for investigation.
- Web server maintenance page — Apache
.htaccessredirecting all traffic to a static “we are doing maintenance” page. Customer-facing more graceful than 403. - Disable the affected plugins via WP-CLI —
wp plugin deactivate <plugin>if you know which plugin was the entry point. - Take the site offline entirely — stop the web server, take down the database connection.
Pick the least disruptive option that stops the active attack. If the attacker is still actively modifying files, take the site offline entirely. If the attack appears to be over (initial compromise complete, no active changes), the WAF block buys you investigation time without taking the site down.
-
Minute 15-25: preserve evidence. Before you change anything:
# Snapshot the database wp db export /tmp/incident-$(date +%F-%H%M).sql # Snapshot the filesystem (use rsync or tar) tar czf /tmp/incident-files-$(date +%F-%H%M).tar.gz /var/www/html # Snapshot the web server access logs for the last 7 days tar czf /tmp/incident-logs-$(date +%F-%H%M).tar.gz /var/log/nginx/ /var/log/apache2/ # Snapshot the audit log if you have one wp db export /tmp/incident-auditlog-$(date +%F-%H%M).sql --tables=wp_simple_history,wp_simple_history_contextsMove these snapshots off the compromised server to a separate location (S3 bucket with write-only credentials, a different host, anywhere the attacker cannot reach). Evidence destroyed by the attacker during cleanup is evidence you cannot recover.
-
Minute 25-40: assess scope. With evidence preserved, identify:
-
Entry point: which vulnerability was exploited? Check the WPScan/Patchstack vulnerability database against your installed plugins. Look at access logs for the timestamps of file modifications:
# Find the IPs that hit unusual paths around the modification time awk '$4 ~ /\[01\/Jan\/2026:0[34]:/' access.log | \ awk '{print $1, $7}' | sort | uniq -c | sort -rn | head -20 -
Persistence: what backdoors did the attacker leave? Common locations:
wp-content/uploads/*.php(PHP files in uploads).wp-content/mu-plugins/<random-name>.php(must-use plugin that always loads).wp-config.phpmodifications addingrequireorincludedirectives.- Admin users created by the attacker (already checked above).
- Cron events that pull payloads from external sources.
-
Data exfiltration: did the attacker get database access? Look at the audit log and access log for SQL injection signatures, unusual REST API calls, or dumps of
wp_usersandwp_usermeta.
-
-
Minute 40-55: decide on the recovery path. Three options, in increasing order of work:
- Surgical cleanup: known plugin vulnerability, identifiable backdoor, no admin compromise. Remove the backdoor, patch the plugin, rotate all secrets, reopen the site. Suitable when scope is small and well-understood.
- Restore from backup: known compromise date, backup that predates it, confidence the backup is clean. Restore, patch the vulnerability that caused the compromise, reopen.
- Rebuild from clean: scope is unclear, compromise date is uncertain, backup may be infected, multiple backdoors found. Stand up a new WordPress install with clean files, migrate database with manual review of suspicious tables, reattach uploads after scanning.
The commander picks one. There is no “let’s do both to be safe” — the rebuild option subsumes the others if needed.
-
Minute 55-60: brief and start recovery. The commander briefs the team on the chosen path, the comms lead drafts the customer communication (typically a “service issue, investigating, will update at HH:MM” — not “we were hacked”), and the technical lead starts the recovery work. The 60-minute window closes with a defensible artifact (preserved snapshots), a documented decision (recovery path), and a comms plan.
Beyond the first 60 minutes is the recovery work itself — covered in separate KB articles for defacement, ransomware, and post-compromise rebuild. The breach-notification clock (72 hours under GDPR, 72 hours under Law 25 for the privacy regulator) starts now if personal data was accessed; have legal aware by minute 30 at the latest.
For organizations where this playbook needs to be ready before the incident, not assembled during one, Stack Harbor runs the IR runbook as part of Enterprise WordPress onboarding, including the comms templates, the legal contact list, and the quarterly tabletop exercise that keeps the team ready. If your WordPress fleet has never run through an IR tabletop, book the exercise.