WordPress ransomware is less common than other ransomware vectors — the WordPress filesystem is partially restorable from WordPress.org and the database is what actually has value — but it happens. An attacker who gets shell access to the server can encrypt files, replace PHP source with garbage, or hold the database for ransom by encrypting the MySQL data directory. The defenses below are about making sure the rebuild path exists before you need it, and the recovery sequence when you do.
What’s happening
WordPress-specific ransomware presents in three common shapes:
- File encryption: every PHP file in
/var/www/htmlreplaced with encrypted content, a ransom note dropped asREAD_ME.txtorwp-content/uploads/HOW_TO_DECRYPT.html. The database is untouched. - Database hold: the attacker dumped a database table (or all of it), then either dropped the live table or encrypted the MySQL data files. A ransom note in a new database row demands payment for the dump.
- Combined: both files and database compromised, often along with backup destruction if the attacker had time before being detected.
The recovery path depends on what is and is not encrypted, and on what backups you can trust. The single principle that makes ransomware recovery possible: an offline replica of the database and the uploads directory, written to immutable storage, that the attacker could not reach even with full shell access. Without that, recovery is paying or rebuilding from scratch.
How to verify
Confirm what is and is not encrypted:
# Are the PHP files actually encrypted or just deleted?
file /var/www/html/index.php
head -c 100 /var/www/html/index.php
ls -la /var/www/html | head -20
# Is the database accessible?
wp db query "SELECT COUNT(*) FROM wp_posts;" 2>&1 | head
wp db query "SHOW TABLES;" 2>&1 | head
# Is the uploads directory affected?
file /var/www/html/wp-content/uploads/$(date +%Y)/*/*.{jpg,png,pdf} 2>/dev/null | head -10
# Are recent backups accessible from this server?
ls -la /var/backups/wordpress/ 2>/dev/null
ls -la /backup/ 2>/dev/null
# Is the offline replica still untouched?
# From the offline replica system - never from the compromised server
ssh backup-host 'ls -la /backups/wp-replica/'
The output tells you the scope. If only PHP files are encrypted and the database and uploads are clean, recovery is straightforward (reinstall PHP, reattach data). If the database is encrypted and you do not have a clean backup, recovery may not be possible without paying — which has its own problems (no guarantee of decryption, legal restrictions in some jurisdictions, funding criminal activity).
Also check for the ransom note:
find /var/www/html -name "READ_ME*" -o -name "*ransom*" -o -name "HOW_TO_DECRYPT*" 2>/dev/null
find /var/www/html -name "*.encrypted" -o -name "*.locked" 2>/dev/null | head
The ransom note identifies the strain, which tells you whether public decryptors exist. NoMoreRansom.org maintains a database of strain-to-decryptor mappings.
The fix
Recovery sequence, with the offline-replica-first principle at the core.
-
Do not pay. Several reasons:
- No guarantee of decryption. Many ransomware operators take the payment and disappear or provide a broken decryptor.
- Reinforcement of the attack model. Paying funds the next attack.
- Legal exposure. In some jurisdictions, paying ransomware operators is restricted (OFAC sanctions in the US, evolving rules in Canada).
- The rebuild path almost always exists if you maintained an offline replica.
The case for paying is rare and should involve legal counsel.
-
Take the compromised server completely offline. Not just maintenance mode — physically disconnected from the network. The attacker may still have shell access; everything you do on a connected compromised server can be watched, interfered with, or used to spread the attack.
-
Stand up a clean replacement. Provision a new VM, new container, new managed instance — wherever your WordPress runs. Install the WordPress version you were running:
# On the new host wp core download --version=6.5.2 wp config create --dbname=wp_recovery --dbuser=... --dbpass=... --dbhost=... wp core install --url=https://example.com --title="Recovery" --admin_user=... --admin_password=... --admin_email=...Do not skip the security baseline — the replacement gets the hardening pack from day one (WAF rules, restricted XML-RPC, 2FA, etc., per the standard hardening KB).
-
Restore the database from the offline replica. This is where the offline replica matters:
# On the new host, restore from the offline backup # Pull the dump from the offline replica (which the attacker could not reach) scp backup-host:/backups/wp-replica/database/wp-$(date +%F).sql.gz /tmp/ gunzip /tmp/wp-$(date +%F).sql.gz wp db import /tmp/wp-$(date +%F).sqlIf your offline replica is more than a few days old, you will lose recent content but you will have a functional site. If you have no offline replica, you are looking at content reconstruction from sources outside WordPress (cached Google results, the Wayback Machine, marketing team’s notes).
-
Restore plugins and themes. Reinstall from clean sources, not from the compromised filesystem:
# Get the plugin list from the database (which you just restored from clean backup) wp plugin list --field=name --format=csv > /tmp/plugins.csv # Reinstall each plugin from WordPress.org or your premium vendor for plugin in $(cat /tmp/plugins.csv); do wp plugin install $plugin --activate done # For premium plugins not on WordPress.org, download from the vendor account # Do not copy from the compromised filesystem - it may contain backdoorsThemes the same way. Custom themes get pulled from version control, not from the compromised server.
-
Restore the uploads directory. If your offline replica includes uploads (it should), pull and reattach:
# Pull uploads from offline replica rsync -av backup-host:/backups/wp-replica/uploads/ /var/www/html/wp-content/uploads/ # Set correct ownership and permissions chown -R www-data:www-data /var/www/html/wp-content/uploads/ find /var/www/html/wp-content/uploads/ -type d -exec chmod 755 {} \; find /var/www/html/wp-content/uploads/ -type f -exec chmod 644 {} \;If uploads were not in the replica and the live uploads are encrypted, this is content that may be lost. Stock images can be re-sourced; user-uploaded content (product photos, document attachments) may not be recoverable.
-
Patch the vulnerability that caused the compromise. Before going live, identify how the attacker got shell access — usually a server-level vulnerability (unpatched kernel, exposed admin panel, weak SSH credentials) rather than a WordPress-level one. Patch that and verify before reconnecting to the public internet.
-
Notify per legal requirements. A ransomware incident involving personal data triggers GDPR/Law 25 notification requirements within 72 hours. The notification should describe what data was potentially accessed, the cleanup actions, and the steps being taken to prevent recurrence. Have legal counsel review before sending.
-
Post-mortem. A ransomware compromise that succeeded means multiple controls failed: the entry point existed, the attacker had time to escalate, monitoring did not catch the activity, and possibly the backups were also reachable. The post-mortem document covers each failure point and the changes that address it. This is not blame; it is the artifact that prevents the next one.
The principle that makes WordPress ransomware recoverable: an offline, immutable replica of the database and uploads, written from the live system but readable only from a separate access path. With it, ransomware is a bad day. Without it, ransomware is a multi-week rebuild that may not fully recover.
Stack Harbor maintains the offline replica architecture as part of enterprise WordPress hosting operations, with quarterly verification that the replica is actually restorable. If your WordPress backup strategy has not been tested against a “the live system is gone” scenario, book the recovery drill.