WordPress Malware Detection Explained
Signature scanning, integrity checks, remote scans and database checks: what each method finds, what it misses and how to combine them.
“Malware scanning” is several different methods sold under one name, and each catches things the others miss. Once you know which method a tool uses, you also know what it will not see, and that is the part that matters when a client’s site starts behaving oddly.
What WordPress malware actually looks like
Most infections on client sites are not dramatic. The attacker wants the site to keep running, because a working site is worth more to them than a broken one. What you find in practice:
- Backdoors: a small PHP file in the uploads folder, or a few lines appended to a legitimate plugin file, usually obfuscated with
base64_decode,gzinflate,str_rot13or functions called through variables. - SEO spam: thousands of pages in Japanese or about pharmaceuticals, often shown only to search engine crawlers, so the owner sees a normal site and Google sees a spam farm.
- Redirects: injected JavaScript in posts, widgets, options or theme files that sends some visitors elsewhere. Often conditional, for example only mobile visitors arriving from Google, only once per IP address, never logged-in users. That is why the client cannot reproduce it.
- Rogue administrators, sometimes hidden from the user list by a few lines of code elsewhere.
- Code in the database rather than in files, for example in
wp_optionsor in post content. - Server configuration changes: rules in
.htaccess, or anauto_prepend_filesetting in.user.inithat loads a file before every request. Wordfence uses that same setting for its firewall, so check what it points to before you delete it.
Signature scanning
A signature scanner compares files against a library of known malicious code: exact hashes of known files and patterns that match known obfuscation. The Wordfence scanner works this way, as do ImunifyAV, which many cPanel and Plesk hosts run on the server, ClamAV and Linux Malware Detect.
It is fast and reliable for known malware families, which covers most mass infections. Its weak points are new or hand-written code that matches no signature, and false positives: plenty of legitimate plugins use base64_decode for licence checks or embedded assets. Scanning thousands of files also costs CPU, which on shared hosting with a 30-second PHP limit means the scan runs in batches or not at all.
Integrity checking
Instead of looking for bad code, integrity checking looks for any difference from a known-good state. WordPress.org publishes checksums for core and for every plugin version in its directory. With WP-CLI, wp core verify-checksums and wp plugin verify-checksums --all compare your files with those. For premium plugins and themes you need your own baseline, taken after an update you trust.
The strength is that it does not care how clever the obfuscation is. A changed file is a changed file. The limits are just as clear. It only sees the folders it watches. It cannot judge whether a change is malicious. And plugins that write into their own folder produce noise until you exclude those paths. The uploads folder needs a separate rule, because it should contain no PHP at all. On a server with shell access, find wp-content/uploads -name "*.php" is a quick check, and every result needs an explanation.
Remote scanning
A remote scanner loads the site the way a visitor does and looks at what comes back: injected scripts, spam links, redirects, and whether the domain is on a blocklist. Sucuri SiteCheck is a well-known free example. Google Search Console’s Security Issues report belongs here too, and it is the one most likely to be noticed first, because Google warns visitors in the browser.
Remote scanning needs nothing installed and is the only method that sees what visitors see. It cannot see a backdoor that changes nothing in the output, and cloaked malware that only shows itself to certain visitors may not show itself to the scanner either.
Database and behaviour checks
File scanners miss code stored in the database. A few queries go a long way. Search post content for script tags you did not put there, for example SELECT ID, post_title FROM wp_posts WHERE post_content LIKE '%<script%';, check that the siteurl and home options hold the address you expect, and list every user with the administrator role. On sites with WP-CLI, wp cron event list shows scheduled tasks, where reinfection code likes to hide.
Behaviour is the last signal: the host reports a spike in outgoing mail, CPU use rises without more visitors, a new administrator appears, a plugin you never installed shows up in the activity log. None of these prove an infection. Each of them justifies a closer look.
On the server or somewhere else
A scanner running inside WordPress uses the site’s own CPU and memory, and code that already controls the site can interfere with it. Some services therefore copy the files to their own servers and scan there. That avoids the load and the tampering, but it means a copy of the site, sometimes including a database dump with customer data, leaves the server. For EU clients that belongs in your processing agreement, and it is worth knowing where those servers are.
Server-level scanning by the host sits outside WordPress altogether, which makes it hard for malware to interfere with. Its reports go to whoever holds the hosting account, which is often the client rather than you.
What WP Octo does and does not do
WP Octo scans your sites for malware as part of the Security add-on; removing what it finds is still up to you. Alongside the scan, WP Octo watches for several signals that often come before or alongside an infection: changed files in plugin and theme folders compared with a baseline, vulnerability checks for plugins, themes and core, an activity log that shows new administrators and plugin installs, a check for log files that anyone can read from the web, and uptime monitoring that can check for content as well as availability. Those signals tell you where to look. The features page lists exactly what is included.
A detection setup that fits an agency
No single method is enough, but you do not need all of them on every site either. For a fleet of client sites, this combination covers most cases:
- File integrity monitoring on every site, with alerts for changes outside your update rounds.
- A signature scanner somewhere: often the host already runs one, otherwise a scanning plugin on the sites that warrant it.
- Search Console set up for every client domain, with security notifications going to your team as well.
- A monthly check for PHP files in uploads and for administrator accounts nobody can explain.
- When anything fires, the procedure in what to do when a WordPress site gets hacked, starting with a backup of the infected state before you touch anything.
Detection is one layer of the setup in WordPress security monitoring for agencies. Most infections start with a known vulnerability, so the cheapest detection is the one you never need, which is why monitoring plugin vulnerabilities comes first.