Skip to content
Blog

How to scan a WordPress site for malware

How to scan a WordPress site for malware: compare files with official copies, find PHP in uploads, check admin users, run ClamAV, and what to do next.

The WP Waterfall team · Guides

To scan a WordPress site for malware, check four things: files that differ from the official copies, PHP files where none belong, administrator accounts you did not make, and anything an antivirus engine such as ClamAV flags. You can do all four with a few commands, and none of them change your site. Do the scan on a copy or after a backup, and treat every result as a lead to read, not a verdict.

Key takeaways

  • Compare plugin and core files to the official copies with wp plugin verify-checksums --all.
  • Look for PHP files in wp-content/uploads, which should hold only media, and for administrators you do not know.
  • Run clamscan for known signatures, then read each finding before you delete anything.

What are you looking for?

Malware on a WordPress site is usually code that lets someone back in or makes money from your visitors. These are the common signs:

  • A web shell or backdoor. A PHP file that runs commands sent to it.
  • PHP in the uploads folder. WordPress stores images and documents there, not code. A .php file in uploads is almost always wrong.
  • Changed plugin or core files. Attackers edit a file that already loads on every page.
  • A new administrator. An account that gives the attacker a normal login.
  • Injected scripts or redirects. Code that sends visitors to another site or adds hidden links.
  • A hidden scheduled task. A WP-Cron event that downloads code again after you delete it.

How do you scan for malware with WP-CLI?

Open a shell in the folder that holds wp-config.php. Start with the plugins, because they are the most common way in:

wp plugin verify-checksums --all

This compares each plugin from wordpress.org with the official copy and prints a warning for any file that differs or is extra. A site with no problem prints Success and the number of plugins it verified. A plugin that does not come from wordpress.org, such as a premium plugin, has no official copy, so it cannot be checked this way.

Core has a similar command, wp core verify-checksums. It can also list extra files that a newer core release added, so read each warning before you act on it.

Then look for code in uploads and for recent changes:

find wp-content/uploads -type f -name '*.php'
find wp-content -type f -name '*.php' -mtime -7

The first command should print nothing, or only small index.php files that say "Silence is golden". The second lists PHP files changed in the last 7 days. Plugin updates change files too, so compare the list with what you updated.

Check who can log in as an administrator:

wp user list --role=administrator --fields=ID,user_login,user_email,user_registered

Every line should be a person you know. Look at the registration date as well.

Finally, list the scheduled events:

wp cron event list --fields=hook,next_run_relative

A hook name you do not recognize deserves a search before you delete it.

How do you scan with ClamAV?

ClamAV is an open source antivirus engine. It knows many known signatures but does not understand what a WordPress file is supposed to do, so it misses custom backdoors. Run it on the content folder:

clamscan -r -i wp-content

-r scans folders recursively and -i prints only infected files. A hit looks like wp-content/uploads/2026/11/eicar.txt: Eicar-Signature FOUND, which is the harmless test file that antivirus vendors publish for this purpose. Keep the signature database current, since new malware appears every day. If you do not have ClamAV on your computer, run it from the official Docker image against a copy of the folder.

What about the database?

Malware also hides in the database: a script added to many posts, an ad injector in a setting, or a hidden administrator. Search for script tags in posts with:

wp db query "SELECT ID, post_title FROM wp_posts WHERE post_content LIKE '%<script%' LIMIT 20"

Change wp_ if your table prefix is different. Scripts in posts are sometimes legitimate, for example an embed, so open each one. Your host's scanner may or may not read the database, so ask.

What should you do when you find something?

  1. Do not just delete the file. Note its path and what it contains, then take a backup of the site as it is so you can study it.
  2. Find the way in. An outdated plugin, a weak password, or a stolen key is usually the cause. Update everything, and remove plugins you do not use.
  3. Restore clean code. The safest fix is a backup from before the infection, then update. A reinstall of core and the plugins from official sources works when you have no clean backup.
  4. Change every credential. Reset the administrator passwords, the database password, and the secret keys in wp-config.php, and remove accounts you do not know.
  5. Scan again and watch for a return in the following days.

How does WP Waterfall scan for malware?

Every file that enters a WP Waterfall site is scanned by two scanners: ClamAV and WP Waterfall's own rules, which look for what antivirus databases often miss, such as PHP backdoors that hide their code, known web shell names, and PHP files in uploads. The scanners run on WP Waterfall's own servers, so your files are not sent to another company.

A migration is scanned before anything is copied. A deploy is scanned after the build and before it goes live, and a bad one stops while the release that was running keeps running. A plugin or theme from the WordPress directory is scanned before it is unpacked. For files that arrive another way, such as SFTP uploads and pictures uploaded in WordPress, a scan runs by itself every 6 hours on live and every 24 hours on staging and previews. Only new and changed files are read.

A file that looks like malware is moved to a quarantine folder where nothing can run it. It is never deleted, and you get a notice. The Protection tab lists the findings with the reason for each, and Scan now starts a scan. Scanners can be wrong, so you can tell support that a finding is safe. WP Waterfall also compares core and wordpress.org plugin files with their official checksums in its integrity check. The database of a running site is not scanned.

Live code is read only on a site that uses Git, which limits what malware can change. See Malware scanning for the full list, and Why we keep live WordPress code read only for the reasoning. An AI assistant connected through the WordPress MCP server can start a scan with scan_for_malware and read the findings with list_malware_findings.

Read next

Try what you just read about.

See it in your own dashboard.