Who Changed It/Guides

How to Preserve Evidence After a WordPress Security Incident

The instinct after a hack is to clean up. Every step of cleaning destroys the information you need to learn how they got in, to tell your insurer what happened, and to decide whether you must notify anyone. Here is what to capture first, in order, and how to keep it usable as evidence.

The short version
  • Copy first, clean second. Restoring a backup over a compromised site erases the evidence of how it happened.
  • Server access logs rotate, often within days. Copy them before anything else.
  • Record a SHA-256 checksum of everything you capture, and write down who captured it and when.
  • If personal data may be affected, the GDPR's 72-hour clock starts when you become aware.
Capture order Logs → DB → Files → Hash Capture in order of volatility before touching passwords or plugins.
NIS2 early warning 24 hours Deadline for entities in scope to send an initial significant-incident notice.
GDPR Art. 33 clock 72 hours To notify your supervisory authority once aware of a personal-data breach.

Why "just restore the backup" is the wrong first move

Restoring gets the site back and answers none of the questions that follow. How did they get in? If you do not know, the restored site has the same hole. When did it start? If the compromise is older than your backup, you have restored the backdoor. What did they reach? Without that you cannot tell customers, your insurer or a regulator anything true.

Preserving evidence takes an hour or two. It is almost always worth that, including when the site is losing money while it is down, because the alternative is to be hacked again next month by the same route.

Step 1: contain without destroying

You need to stop the damage without altering the scene.

Do first · Preserve the scene
  • Do put the site behind maintenance mode or restrict access by IP at the web server or firewall.
  • Do take a snapshot at the hosting level if your provider offers one. It captures files, database and often the logs at a single moment.
Do not touch yet · Avoid destroying evidence
  • Do not delete suspicious files, users or plugins yet.
  • Do not update everything. Updates overwrite modified files and their timestamps.
  • Do not change passwords before you have captured the database. The user table and session data are evidence. Rotate credentials straight afterwards.

Step 2: capture in order of how fast it disappears

01 · Most volatile

Server logs, first

Web server access and error logs are the best record of how an attacker got in, and the shortest-lived. Many hosts keep a few days. Download everything available, including the rotated and compressed files. If you cannot find them, ask the host's support for the logs for the affected period in the same message in which you tell them about the incident.

02 · Live state & sessions

The database

wp db export incident-2026-11-20-db.sql --add-drop-table

This preserves the user accounts and when each was registered, active session tokens with their IP addresses, options that may have been changed, injected content, and the table of any activity log you run.

03 · Modification timestamps

The files, with timestamps intact

tar --numeric-owner -cpzf incident-2026-11-20-files.tar.gz -C /var/www example.com

Archive the whole web root, uploads included. Modification times are evidence: they show which files changed, and together with the access log, which request changed them. Copying files over FTP file by file usually resets those times, which is why an archive made on the server is better.

04 · Persistence & host layer

Anything outside WordPress

Cron entries for the site's system user, .htaccess and server configuration, the list of SFTP and SSH accounts and keys, and the hosting control panel's own login history if it has one.

Step 3: make the copies provable

Evidence is worth little if you cannot show it is unchanged since you took it.

sha256sum incident-2026-11-20-* > incident-2026-11-20.sha256

Then keep a plain text note alongside, written as you go:

Chain-of-custody log template · UTC

2026-11-20 09:14 UTC — J. Meyer — noticed redirect to pharmacy site on /checkout
2026-11-20 09:31 UTC — J. Meyer — site restricted to office IP at firewall
2026-11-20 09:40 UTC — J. Meyer — downloaded access logs 2026-11-06 to 2026-11-20 from host panel
2026-11-20 09:52 UTC — J. Meyer — db export + file archive created on server, checksums recorded
2026-11-20 10:05 UTC — J. Meyer — copies moved to encrypted drive; originals untouched

That note is a chain of custody. It does not need to be elaborate. It needs times in UTC, a name against each action, and no gaps. Store the copies somewhere the compromised server cannot reach, and work on duplicates.

Step 4: export the application's own record

If an activity log was running, it holds what server logs cannot: which account did what. Export it for a period starting well before the first sign of trouble. Look especially for new administrator accounts, role changes, plugin installs, file editor use, and changes to the admin email or site address.

Treat that log with some suspicion. An attacker with administrator or database access may have deleted entries. Whether you can tell depends on the tool: a log whose records are cryptographically chained will report missing or altered rows, and an ordinary one will look complete either way. Note which kind you have in your custody note.

Step 5: know which clocks are running

24 hours NIS2

Entities in scope must send an early warning within 24 hours of a significant incident.

72 hours GDPR, Article 33

If personal data was or may have been accessed, you must notify your supervisory authority within 72 hours of becoming aware, unless the breach is unlikely to result in a risk to people. You can notify with partial information and add to it later. You cannot notify late without explaining why.

Immediate Payment cards

If card data may be involved, your acquirer's rules apply immediately, and they may require a specific forensic investigator. Stop and call them before touching anything further.

Before clean-up Cyber insurance & contracts

Most policies require prompt notice and some require you to use the insurer's own responders. Cleaning up first can jeopardise the claim. If you run the site for a client, your agreement probably sets a notification period.

Step 6: only now, clean and recover

With copies made and checksummed, the site can be cleaned or rebuilt. Work out the entry point from the evidence before restoring, so that you restore to a state from before it and close the hole. Then rotate everything: all WordPress passwords, the authentication salts in wp-config.php, database and SFTP credentials, API keys and application passwords. The practical walkthrough is in site hacked: how to find out what changed.

When to hand it to someone else

Get professional help when card data or health data may be involved, when you expect a legal dispute or an insurance claim, when the site has been reinfected after a previous clean-up, or when you simply cannot find the entry point. Evidence you have preserved as above is what a responder will ask for first, and it makes their work shorter and cheaper. The author of this guide does this for a living at WP Server Guard; any competent incident responder will want the same material.

Common questions on preserving WordPress incident evidence

Why shouldn't I restore a backup immediately after my WordPress site is hacked?
Restoring a backup overwrites the database, active sessions and file timestamps that show how the attacker got in and what data was accessed. If the vulnerability or backdoor predates the backup, the site will be compromised again, and you will lack the evidence required by insurers or data protection regulators.
What is the most urgent evidence to capture on a compromised WordPress server?
Web server access and error logs come first because many hosts rotate or purge them within 24 to 72 hours. Immediately after downloading the logs, export the MySQL database and create a tar archive of the web root on the server so file modification timestamps are preserved.
How do I prove that forensic copies of my WordPress database and files were not altered?
Generate a SHA-256 checksum manifest (using sha256sum) right after creating the database dump and file archive, store the archives and checksum file off the compromised server on read-only or encrypted media, and record every action with UTC timestamps and the operator's name in a chain-of-custody note.

Being ready next time

Most of the difficulty above comes from evidence that was never recorded or was easy to erase. Three preparations change that: keep server logs for at least 90 days, keep backups off the server, and run an activity log that can show whether it has been tampered with. Who Changed It, which this site documents, hash-chains its records and signs its exports for that reason; this page explains how.