Home / Guides

Server guide

WordPress Malware Removal Checklist

If you run a WordPress site, this guide helps small businesses, agencies and hosting teams identify and clean malware. You’ll learn quick checks, removal steps and how to stay safe.

8 min readUpdated November 2026 by the RootManage teamWorks on Ubuntu, Debian, AlmaLinux and Rocky unless noted

The short answer

Use a malware scanner, review files and database, remove infected code, restore clean backups, and harden security. Follow the checklist to protect your site.

What is WordPress malware and why it matters

WordPress malware includes injected scripts, backdoors, and malicious plugins that hijack site functionality. Common types include defacement code, hidden iframes that redirect visitors to phishing pages, and cryptominers that consume server resources. Attackers often exploit outdated core files or vulnerable extensions to gain access. Once installed, these scripts can persist even after cleaning the database, making thorough removal essential for restoring trust and preventing data theft.

The risks extend beyond immediate downtime. Infected sites may be blacklisted by search engines, leading to lost organic traffic and revenue. User data, including login credentials and payment details, can be exfiltrated to remote servers. Additionally, compromised sites are frequently used to launch further attacks against other networks. For agencies and hosting providers, a single infected client site can damage your reputation and violate service level agreements, highlighting the need for proactive monitoring and rapid response protocols.

  • Check for unexpected file modifications in the wp-content directory
  • Review cron jobs for suspicious scheduled tasks
  • Inspect database tables for hidden admin accounts

How to check if your WordPress site is infected

Start by running a reputable scanner like Wordfence or ClamAV to detect known malware signatures. These tools check file modifications and compare them against clean versions. Always create a full server snapshot or backup before scanning a production environment. If the scanner flags a file, do not delete it immediately. Instead, isolate the file to inspect its contents and understand how it was injected into the system.

Next, verify file integrity using the md5sum command to compare hashes of critical WordPress files against known good values. Check the database for suspicious entries by looking for unexpected posts, users, or options. Look for obfuscated code in theme or plugin files that appears as long strings of random characters. This manual review helps identify stealthy malware that automated scanners might miss.

terminal
md5sum wp-config.php wp-login.php

Look for hash mismatches compared to your original source files. Also check for user accounts you do not recognize or database entries with hidden iframes or JavaScript redirects. If you find anomalies, note the file paths and timestamps for your security engineer to analyze the infection vector.

Steps to remove malware and restore the site

Before touching files, take a full snapshot or backup of your server. This allows you to roll back if a change breaks the site. Isolate the infected server from the network if possible to prevent further spread. Work from a clean terminal session, ensuring your SSH client and local machine are free of malware. Document every file you modify so you can track the scope of the infection and verify that all malicious code is removed during the cleanup process.

Focus on cleaning files and the database systematically. Remove unknown or recently modified plugins and themes that you do not recognize. Replace core WordPress files with fresh copies from the official source to ensure integrity. Sanitize the database by removing suspicious comments, posts, or options that contain injected scripts. After cleanup, change all passwords, including database, FTP, and admin accounts, to prevent the attacker from regaining access to your system immediately after the restoration.

  • Replace core WordPress files with fresh downloads.
  • Delete unknown plugins and themes from the filesystem.
  • Scan the database for injected JavaScript or iframes.
  • Update all remaining plugins and themes to the latest versions.
terminal
# Example: List recently modified files in the WordPress root
find /var/www/html -type f -mtime -7 -ls

# Example: Check for suspicious PHP files in uploads
find /var/www/html/wp-content/uploads -name '*.php' -ls

# Note: These are read-only examples. Review output before taking action.

Verify that the site loads correctly and check the browser console for errors. Monitor server logs for any repeated failed login attempts or unusual file access patterns. Ensure that all security plugins are active and that automatic updates are enabled to prevent similar issues in the future.

What to avoid during cleanup

During a cleanup it is tempting to delete files that look suspicious, but removing WordPress core files or theme files can break the site and create new vulnerabilities. Always compare the files against a clean WordPress install and restore only the ones that differ. Avoid disabling security plugins or firewall rules that have been working; they are your first line of defense. If a plugin is flagged, investigate the source before deactivating it, and keep a backup of the current state. Never run scripts or installers from untrusted sources. Many malware removal guides recommend downloading a script that purges files, but such scripts can overwrite legitimate data or install new backdoors. Stick to proven tools like wp-cli and clamav for scanning, and verify any downloaded binaries with checksums. Keep the server’s operating system and all software up to date, and never turn off SELinux or AppArmor to “fix” a problem.

  • - Verify file integrity before deletion
  • - Keep a recent backup
  • - Use trusted tools only
  • - Do not disable active security measures
terminal
# Example: create a quick backup of the WordPress directory
# Make sure you run this from a safe location
mkdir -p /root/backup
cp -a /var/www/html /root/backup/wordpress-$(date +%F)
# Verify file integrity with WordPress core checksum
wp core verify-checksums

After cleanup, check that the site loads correctly, that no error messages appear in the logs, and that the security plugins report a clean status.

How to harden WordPress after removal

After cleaning an infected WordPress site, start by tightening the core configuration. Disable file editing from the dashboard by adding define('DISALLOW_FILE_EDIT', true); to wp-config.php. Turn off PHP execution in the uploads directory with a simple .htaccess rule. Review the wp-config.php file for default values and replace any weak salts with fresh ones generated from the WordPress secret-key service. Ensure the site runs under a dedicated, non‑root system user and that the web server only has read access to core files, while write permissions are limited to the wp-content/uploads folder.

Keep the entire stack up to date. Apply the latest WordPress core, theme, and plugin releases promptly, using the built‑in updater or the command line with WP‑CLI. Set file and directory permissions to the recommended values: directories 0755, files 0644, and the wp-config.php file 0600. Enable automatic security updates for the operating system and PHP. Finally, activate a monitoring solution that logs file changes, monitors login attempts, and alerts on suspicious activity, so you can react quickly if a new compromise occurs.

  • Add DISALLOW_FILE_EDIT to wp-config.php.
  • Restrict PHP execution in wp-content/uploads via .htaccess.
  • Set directory permissions to 0755 and file permissions to 0644.
  • Run regular WordPress core, theme, and plugin updates.
  • Implement file integrity monitoring and login‑attempt alerts.
terminal
## Example commands (review before executing)
# Install WP‑CLI if not present
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

# Update core, plugins, and themes
cd /var/www/html/your-site

After running the commands, verify that wp-config.php is readable only by the web server user, that no files have world‑writable bits, and that the WP‑CLI output shows the latest versions installed. Check the web server error log for any permission‑related messages and confirm that your monitoring tool reports a clean baseline.

How to keep your WordPress site clean

Keep your WordPress installation clean by scheduling regular security scans. Use a reputable scanning tool or plugin that checks core files, themes, and plugins for known malware signatures. Run the scan at least weekly and after any major change, such as a theme update or new plugin installation. Review the scan report promptly and remove or replace any flagged items. Consistent scanning helps you catch infections early before they spread or affect visitors.

Maintain reliable backups and enforce strict access controls. Store backups off‑site and test restoration procedures quarterly to ensure they work. Limit administrator accounts to trusted personnel and use strong, unique passwords with two‑factor authentication. Assign the lowest possible role to each user and disable file editing from the WordPress dashboard. These practices reduce the chance of a breach and give you a quick recovery path if one occurs.

  • Schedule weekly scans with a trusted plugin or CLI tool.
  • Create daily off‑site backups and verify restore capability.
  • Enable two‑factor authentication for all admin users.
  • Restrict file permissions to the minimum required.
  • Remove unused themes and plugins promptly.
terminal
wp cli scan --type=malware   # Example: run a WP‑CLI malware scan; review output before acting

After running the scan, look for any files marked as infected or modified unexpectedly. Verify that backup files exist and can be restored, and confirm that only authorized users have admin access.

When to seek professional help

If you notice that the site is suddenly showing strange pop‑ups, redirects to unrelated domains, or the admin login page has been replaced, these are strong indicators that the infection is beyond basic cleanup. Similarly, if core WordPress files have been modified, unknown users appear in the user list, or the server logs show repeated brute‑force attempts that you cannot stop, you should involve a security specialist. These signs often mean the compromise is deep, affecting the underlying OS or database, and a professional can safely isolate and remediate the threat without risking data loss.

When the site is part of a larger business operation, downtime directly impacts revenue and reputation. If you lack in‑house expertise to verify that all backdoors are removed, or you need to ensure compliance with industry standards, a managed support service can provide a thorough forensic analysis, apply hardened configurations, and set up ongoing monitoring. Trusting experts also helps you avoid re‑infection cycles and gives you a documented remediation plan for future reference.

  • Unexpected admin users or changed passwords
  • Core WordPress files differ from official checksums
  • Server logs show persistent unauthorized access attempts
  • Site content is altered or injected with hidden iframes
  • Performance degrades sharply without clear cause
terminal
# Example: list files that are not owned by the web userind /var/www/html -type f ! -user www-data -ls
# Review recent changes in WordPress core files
cd /var/www/html && wp core verify-checksums
# These commands are examples; read them fully before execution.

The result should give you a clear view of files with abnormal ownership and any core file mismatches. Use this information to discuss the scope of work with a qualified security provider.

If you would rather have engineers do this for you, see Linux server management, Windows server management or emergency malware cleanup.

Questions people ask

What tools can I use to scan my WordPress site for malware?

Use a reputable scanner such as Wordfence, Sucuri SiteCheck, or the free ClamAV package with a WordPress plugin. These tools compare files against known signatures, check core integrity, and flag suspicious code. Run them from the dashboard or via command line for deeper analysis.

How often should I back up my WordPress site before cleaning?

Create a full backup—including files and database—before any cleaning. Schedule automated backups at least weekly, and take an additional manual snapshot right before you start the removal process. Store backups off‑site or on a separate volume for safety.

Can I remove malware without affecting my content?

Yes, you can often clean infected files while keeping your posts, pages, and media intact. Replace only the compromised core, theme, or plugin files with clean versions. Verify the database content remains unchanged, then test the site before publishing any changes.

What if I find malware in the database but not in files?

If malware resides only in the database, it is usually hidden in posts, options, or user meta. Use a tool like WP‑CLI’s search‑replace or a database scanner to locate and delete the malicious payload. After cleaning, run a full site scan to confirm no remnants remain.

Want a person to look at it?

Tell us what you see. We reply with what we think is wrong and what it would take to fix it.