Reports indicate an incident that converted close to 2,000 WordPress sites into malware infrastructure. This tutorial explains how to treat an individual WordPress site exposed in such a campaign: how to detect compromise, remove malicious artifacts, restore safe operation, and harden the site to reduce the chance of repeat abuse. The steps below are implementation-focused and suitable for site owners, developers and hosting administrators.
- Treat affected WordPress sites as fully compromised until proven otherwise.
- Preserve evidence before making changes; prefer restoring from a clean backup when possible.
- Rotate all credentials and enable 2FA; restrict plugin and theme sources to reputable vendors.
Why this matters (threat model)
When attackers turn WordPress sites into malware infrastructure they commonly use compromised sites as hosting for malicious files, command-and-control endpoints, or redirectors. Infected sites can damage reputation (blacklisting by search engines and security vendors), lead to traffic loss, and expose site visitors to malware or fraud. Treat each affected site as potentially fully compromised until proven otherwise.
Prerequisites and safety precautions
- Access to the site’s files (SFTP/SSH) and its web host control panel or administrative API.
- Administrative WordPress account and access to the database (phpMyAdmin, mysql client, or host-provided tool).
- Ability to take a full backup (files + DB) and to restore from a known-good backup if available.
- A maintenance window or a temporary offline mode; inform stakeholders before taking invasive actions.
- Out-of-band credentials for FTP/hosting control panel and WordPress admin; do not reuse the breached credentials until they’re rotated.
High-level workflow
- Contain the site to prevent further abuse and limit visitor exposure.
- Preserve evidence: take full backups of files and database for forensics before changes.
- Detect and identify malicious files, DB entries, and altered configuration.
- Clean and restore the site from verified clean sources.
- Harden configuration and credentials; monitor for recurrence.
- Validate the site is clean and remove temporary containment.
Step-by-step instructions
1. Immediate containment
- Put the site into maintenance mode or serve a temporary static page to stop further hosting of malicious content to visitors. If maintenance mode is unavailable, consider using the host control panel to disable the public document root or return a 503 from the web server.
- Reset all administrative passwords that could be affected: WordPress administrator accounts, hosting control panel, FTP/SFTP/SSH, database user passwords, CDN and DNS provider accounts.
- Notify the hosting provider and request any available network-level mitigation (block suspicious outbound connections, isolate the account).
2. Preserve evidence
- Download a full file-system archive (tar/zip) of the site’s document root and any scheduled tasks (cron), plus a SQL dump of the database. Store copies offline and, if needed, hand them to a forensic provider.
- Record timestamps: filesystem mtime/ctime and web server access/error logs for the period of suspected compromise.
3. Detection: look where malware typically hides
Use the preserved snapshot for scanning rather than the live site if possible. Look for unusual or recently modified files and suspicious PHP code patterns.
- Known hiding places: theme and plugin directories, /wp-content/uploads, wp-config.php, mu-plugins and wp-includes.
- Search for PHP code obfuscation techniques: base64_decode(, eval(, gzinflate(, preg_replace( with /e, create_function(, or long strings of random-looking characters.
- Check for unknown scheduled events in the wp_options table (option_name LIKE ‘%cron%’ or entries in wp_postmeta that look like tasks).
- Inspect .htaccess or webserver config for redirects, rewrite rules, or directives that expose files or hide access.
- Review recently added admin users in wp_users and unusual usermeta entries.
- Scan for files served with incorrect MIME types or executable permissions in the uploads directory.
4. Remove malicious artifacts safely
If a clean recent backup exists from before the compromise, restoring files and the database from that backup is usually the quickest safe option. If not, follow a surgical cleanup:
- Replace core WordPress files with a fresh copy from the official release matching the installed major version. Do not overwrite wp-config.php or the wp-content directory yet.
- Delete all inactive plugins and themes. Reinstall trusted versions of required plugins/themes from official sources.
- Manually inspect and remove suspicious files found earlier. For obfuscated PHP, move files to a quarantine directory for offline analysis before deletion.
- Clean any malicious DB entries identified (malicious options, injected posts, rogue users). Export a SQL diff so changes are auditable.
- Review and restore .htaccess or webserver config from a known-good template; remove unexpected rules.
5. Restore functionality and harden
- Rotate all credentials again after cleanup: WordPress admin, database user, hosting panel, FTP/SFTP/SSH, CDN, and DNS.
- Ensure file and directory permissions follow recommended values: typically 644 for files and 755 for directories, with wp-config.php tightened to 600/640 where supported by hosting.
- Enable or install a reputable Web Application Firewall (WAF) at the host or CDN level to block common attack patterns.
- Apply all updates for WordPress core, themes and plugins. Prefer minimal plugins and only those from reputable sources.
- Limit administrator accounts and use principle of least privilege for other accounts. Consider implementing role-based access controls and a secondary admin email verification.
- Enforce strong authentication: enable two-factor authentication (2FA) for all admin accounts and for hosting control panels where available.
- Disable PHP execution in the uploads directory by placing an appropriate webserver rule (for example a .htaccess file with “php_flag engine off” where supported) and block direct execution of uploaded files.
- Harden database access: restrict the database user to the specific database and, where possible, allow connections only from the webserver host.
6. Monitoring and validation
- Use file-integrity monitoring to detect new or modified files (tripwire-like tooling, or WordPress plugins that check checksums against official releases).
- Set up external scanning with reputable site-scanners (security vendor site-checks) and Google Search Console to detect warnings or manual actions.
- Monitor outgoing network activity from the hosting account for unusual connections or sustained outbound traffic spikes.
- Keep daily or frequent backups and periodically test restores to verify backup integrity.
Common failure modes and troubleshooting
- Residual backdoors: attackers often leave multiple backdoors. If reinfection occurs after cleanup, re-check non-obvious locations (mu-plugins, wp-content/uploads, database-stored PHP in options or posts).
- Compromised credentials elsewhere: attackers may have reused passwords; ensure credentials for linked services (FTP, email hosted with same provider, Git) are rotated.
- Compromised local machines: if an admin’s workstation is infected, changing credentials alone will not stop recurring attacks. Scan and clean local systems.
- False positives in scanning tools: manual review of flagged files is important before deleting anything critical.
Trade-offs and practical decisions
Complete rebuild vs surgical cleanup: restoring from a clean backup or rebuilding the site from known-good sources is more reliable but may be slower and disruptive. Surgical cleanup can return a site to service faster but requires confidence that all backdoors are found. Choose based on business risk tolerance and availability of clean backups.
Cost vs coverage: paid WAFs and security services reduce risk but add ongoing cost. For many small sites, enforcing updates, strong credentials and 2FA provides substantial protection at minimal cost.
Short FAQ
- Q: How do I know if my site was used as malware infrastructure?
A: Look for served files that are unrelated to your site (binary payloads), unusual redirects, blacklisting notices from search engines or security vendors, and spikes in outbound connections. Preserve evidence before changing anything.
- Q: Can I clean the site myself?
A: Yes, if you have access to files, DB and understand basic PHP scanning. If unsure, involve your host or a security professional—especially when many sites are affected.
- Q: Is it safe to restore from backup?
A: Only if the backup predates the compromise and you are confident it’s clean. Always scan the backup and rotate credentials after restore.
Practical next steps
- If responsible for multiple WordPress sites, inventory them and prioritize those with public traffic or ecommerce for immediate review.
- Implement 2FA and a small set of vetted plugins across all sites, and schedule timely updates.
- Plan a test restore from backups quarterly so recovery procedures are verified.
Note: reporting has mentioned a campaign affecting nearly 2,000 WordPress sites. The guidance above is a practical, defensive playbook for site owners facing the same class of compromise. Specific indicators of compromise will vary per incident; when available, use indicators published by your hosting provider or security vendor as primary references.
