After a breach, a suspicious update, or the appearance of unfamiliar code, you do not always need to compare the entire site with a backup immediately. WP-CLI can verify the checksums of WordPress core files, as well as those of many plugins and themes.
This check quickly shows which files differ from the original versions. However, it is not a complete security audit: custom code, premium extensions, mu-plugins, uploaded files, and the database must be checked separately.
What WP-CLI Checks
A checksum is a digital fingerprint of a file. WP-CLI compares local files with reference versions published by official sources. If a file has been modified, deleted, or is missing, the command reports a mismatch.
WordPress Core verification covers the standard files for a specific WordPress version. For plugins and themes, checksums are generally available for packages from the official WordPress.org directory. Unique, premium, or internally developed extensions may not have a reference set.
The check does not determine by itself whether a change is malicious. An updated file, a local patch, or an intentionally modified theme can also differ from the original.
- Core: WordPress core files.
- Plugins: installed extensions for which official checksums are available.
- Themes: packages with a supported checksum source.
- Not automatically covered: all files in wp-content, the database, and the site's configuration.
Preparing for the Check
Run the commands from the directory where WordPress is installed. Make sure WP-CLI is available and that the current user has permission to read the site files. On a production site, it is advisable to create a backup or snapshot first, especially if you plan to reinstall components after the diagnosis.
Save the verification results before making any changes. This will help you compare the site's state before and after restoration and provide technical details to your hosting provider or an incident response specialist.
- Make sure you are working on the intended site, not another WordPress installation on the system.
- Record the WordPress version, active plugins, and active theme.
- Do not delete suspicious files before completing evidence collection.
- Do not use --allow-root unless necessary; running as root can cause file ownership problems.
cd /var/www/example.com
wp --info
wp core version
wp plugin list
wp theme list
Commands to Check Core, Plugins, and Themes
A basic verification consists of three commands. They do not modify files; they only compare them with available reference versions.
- For the core, use wp core verify-checksums.
- For all installed plugins, use wp plugin verify-checksums --all.
- For all installed themes, use wp theme verify-checksums --all.
wp core verify-checksums
wp plugin verify-checksums --all
wp theme verify-checksums --all
How to Save the Results and Interpret Errors
Evaluate the command output not only by whether an error occurred, but also by the specific file involved. A modified message means that the file exists but its contents do not match the reference. A missing message indicates that a file is absent, while a message about additional files may point to third-party objects in the directory.
Save the output to text files. If a command ends with an error, this does not always indicate a breach: the cause may be a missing reference for a custom component, an incorrect version, or a problem accessing the checksum source.
- Compare the file name, path, and component to which it belongs.
- Check the file's modification date and owner through the operating system.
- Make a copy of a suspicious file before replacing it.
- Do not edit the original file during the investigation.
mkdir -p security-check-$(date +%F)
wp core verify-checksums 2>&1 | tee security-check-$(date +%F)/core.txt
wp plugin verify-checksums --all 2>&1 | tee security-check-$(date +%F)/plugins.txt
wp theme verify-checksums --all 2>&1 | tee security-check-$(date +%F)/themes.txt
What to Do After Finding Mismatches
Do not reinstall everything without investigating first. Determine whether the modified file belongs to Core, a plugin, or a theme, and whether the changes may have been intentionally made by a developer. If the file contains PHP code, unfamiliar inclusions, obfuscation, calls to eval or base64_decode, or suspicious remote requests, examine it especially carefully. An isolated code fragment is not automatic proof of a breach, but it is a reason for manual analysis.
For a standard Core installation, it is safer to download clean files for the same version from a trusted source. The --force option overwrites local files, so always save a copy before using it and make sure you will not overwrite configuration files or custom changes.
- Save suspicious files, logs, and metadata before cleanup.
- Reinstall the component from the same trusted source and, where possible, the same version.
- Run the checksum verification again after replacement.
- If the infection returns, check administrator accounts, cron jobs, SSH access, and server logs.
wp core download --force --skip-content
wp plugin install plugin-slug --force
wp theme install theme-slug --force
Components That Require Separate Checks
Checksum verification does not cover all of a site's code. The wp-content/mu-plugins directory contains must-use plugins, which can load automatically without standard activation. Review their files manually or compare them with a copy from the relevant repository.
Also check drop-in files in wp-content, including object-cache.php, advanced-cache.php, and db.php if they are present. These files can affect WordPress execution and remain unnoticed during standard plugin verification.
The uploads directory is normally intended for media, but PHP files can appear there on an incorrectly configured server. Check whether any are present and make sure script execution in the uploads directory is disabled in the web server configuration.
- wp-content/mu-plugins
- wp-content/*.php
- wp-content/uploads
- wp-config.php
- .htaccess or the web server configuration
- Cron jobs and unfamiliar WordPress users
find wp-content/mu-plugins -type f -maxdepth 2 -print 2>/dev/null
find wp-content/uploads -type f -name '*.php' -print
find wp-content -maxdepth 1 -type f -name '*.php' -print
Common Mistakes During Verification
The most common mistake is treating checksum verification as a complete malware scan. It does not detect suspicious database entries, changes to server settings, stolen tokens, or malicious rules in .htaccess.
Another problem is reinstalling a plugin over infected files without checking access controls. If an attacker has administrator or FTP access, malicious code may reappear. After an incident, change passwords, revoke active sessions, and review access keys.
Do not delete every file that lacks checksums either. The absence of a reference set only means that automated comparison is not possible. Such components require the original repository, a vendor-provided archive, or a verified backup.
- Do not confuse modified with confirmed malware.
- Do not restore the site from an unverified backup.
- Do not run commands as root unless the specific environment requires it.
- Do not limit the investigation to wp-admin or Core files.
Frequently asked questions
Does wp core verify-checksums check wp-config.php?
No. wp-config.php contains unique site settings and is not a standard Core file for this comparison. Check it separately, along with .htaccess and the web server configuration.
Why can't WP-CLI verify a premium plugin or custom theme?
An official checksum set may not be available for them. Compare the files with the vendor's original archive, the relevant repository, or a verified backup.
Should I immediately delete a file with a checksum error?
No. First save a copy and the verification log, determine the origin of the change, and only then replace the file with a clean version or provide it to a specialist for analysis.
Is this check enough after a WordPress breach?
No. It is a fast way to find changes in known files, but full incident response also covers the database, users, logs, cron jobs, uploaded files, access credentials, and server settings.
Conclusion
WP-CLI provides a fast first indication after a breach or suspicious update: it helps identify modified and missing Core, plugin, and theme files without manually comparing the entire site.
Use the results as part of incident response: preserve evidence, reinstall components from trusted sources, check mu-plugins, uploads, and drop-ins, and repeat the verification after cleanup.