Home / Guides / WordPress handbook / Chapter 02
WordPress handbook · Chapter 02 · Security
Complete WordPress Security Hardening
Hardening means reducing the number of ways a site can be compromised and limiting the damage when one succeeds. This chapter starts from how WordPress sites are actually broken into, then covers each control: what it protects against, how to apply it, how to check it works, and what it can break.
On this page
- Threat model: how WordPress sites are really compromised
- The principle of least privilege
- Why administrator accounts must be limited
- Authentication: passwords and multi-factor authentication
- Sessions and cookies
- Authorization, nonces, application passwords and API access
- Updates: why outdated plugins and themes are dangerous
- Identifying abandoned extensions
- Evaluating a plugin before installing it
- Hosting, file permissions and directory listing
- Protecting configuration and secrets
- HTTPS enforcement and security headers
- Database security in brief
- Security logging and monitoring
- Malware monitoring
- Vulnerability management
- Security priority matrix
Threat model: how WordPress sites are really compromised
Security effort should follow real risk, not folklore. Public vulnerability databases and incident-response reports have pointed the same way for years. The great majority of newly disclosed WordPress vulnerabilities are in plugins, a smaller share in themes, and very few in core. Most compromises come from a short list of causes:
| Attack path | How it works | Primary defences |
|---|---|---|
| Vulnerable plugin or theme | A flaw is disclosed (or patched, and attackers diff the patch). Automated scanners probe millions of sites for the vulnerable version within hours or days. Typical flaw classes: broken access control, SQL injection, stored XSS, arbitrary file upload, privilege escalation. | Fast updates, fewer plugins, vulnerability monitoring, WAF virtual patching |
| Credential attacks | Brute force and credential stuffing (passwords leaked from other sites) against wp-login.php, XML-RPC and application passwords. | Unique strong passwords, multi-factor authentication, login rate limiting |
| Stolen sessions and phishing | An administrator's cookie or password is stolen by malware on their device or a phishing page. | MFA (phishing-resistant where possible), short sessions for admins, fewer admin accounts |
| Nulled or pirated premium plugins | "Free" copies of paid plugins often contain backdoors. | Only install from the official directory or the vendor |
| Supply-chain compromise | A legitimate plugin is sold to, or hijacked by, a malicious party who ships a bad update. | Watch ownership changes, update monitoring, file integrity monitoring |
| Hosting-level compromise | A breached hosting control panel, reused SFTP password, or another site in the same shared account being infected. | Account isolation, SSH keys, separate hosting accounts per client, MFA on the panel |
| Sensitive file exposure | Publicly downloadable debug.log, database dumps, .git folders, .env files, backup archives, wp-config.php.bak. | Keep these out of the web root; server deny rules |
Notice what is not on the list: hiding the WordPress version, renaming the database prefix, or changing the login URL. Those measures reduce log noise but barely slow down a targeted attacker. Do them, if you choose, after the controls that matter.
The principle of least privilege
Least privilege means every person, account, process and integration gets exactly the access it needs for its job, and no more, for as long as it needs it and no longer. The point is to limit blast radius. You assume that some account will eventually be compromised, and you make sure that a compromised account can do as little as possible.
On a WordPress site, privilege exists at several independent layers. Each one needs to be scoped:
| Layer | Over-privileged example | Least-privilege alternative |
|---|---|---|
| WordPress roles | A content writer has an Administrator account "because it's easier" | Author or Editor role; Shop Manager for store staff; a custom role if needed |
| Hosting control panel | The marketing agency has the owner's panel login | Sub-user or collaborator access limited to one site, ideally time-limited |
| File access | One shared FTP password used by everyone for years | Individual SFTP/SSH accounts with keys, scoped to the site directory, removed when work ends |
| Database user | WordPress connects as root, or as a user with rights on every database on the server | A dedicated user with privileges only on this site's database (Chapter 08) |
| API keys and integrations | A full-access WooCommerce REST key for a shipping integration that only reads orders | Read-only key; separate keys per integration, so one can be revoked alone |
| Application passwords | A personal administrator's application password used by an automation tool | A dedicated service user with the minimum role, and its own application password |
| Email and DNS accounts | Everyone shares the registrar login | Named accounts with MFA; registrar lock on the domain |
WordPress roles and capabilities
WordPress authorisation is built on capabilities (for example edit_posts, publish_pages, upload_files, manage_options, install_plugins). Roles are named bundles of capabilities. The defaults:
- Administrator: everything on a single site, including installing plugins and editing code. Effectively full control of the server account.
- Editor: publishes and manages all content, including other users' content. Holds
unfiltered_htmlon single sites, so editors can insert scripts. Treat it as a trusted role. - Author: publishes and manages their own posts and uploads files.
- Contributor: writes but cannot publish or upload.
- Subscriber: reads and manages their own profile. Also the default role for public registrations.
- WooCommerce adds Shop Manager (manages products, orders and store settings, without plugin installs) and Customer.
Plugins can add roles and capabilities, and they store changes permanently in the database (the wp_user_roles option), so deactivating a plugin does not always remove capabilities it granted. Role editor plugins can audit this. Review roles after removing membership, LMS or ecommerce plugins.
Why administrator accounts must be limited
An Administrator can install a plugin, and a plugin is arbitrary PHP code. So every Administrator account is equivalent to server-level code execution in the hosting account: reading wp-config.php, dumping the database (including customer data and password hashes), planting backdoors and sending spam. Each extra admin account is one more password to be phished, reused or brute-forced, and one more person whose infected laptop can hijack the site.
- Keep the number of Administrators as small as practical: typically one or two named people, plus a break-glass account stored in a password manager.
- Give every person their own account. Shared logins make audit logs meaningless and make leavers impossible to remove cleanly.
- Give contractors access for the duration of the job, then downgrade or delete the account.
- Use a separate low-privilege account for day-to-day publishing, even if you also hold an admin account.
Auditing administrators
wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
# On Multisite, super admins are listed separately:
wp super-admin list
Investigate any administrator you cannot account for. An unknown admin, especially one with a random-looking username or a recent registration date, is a common sign of compromise; see the incident-response section of Chapter 11. Before deleting a legitimate account, reassign its content, or WordPress will delete the posts it authored:
wp user delete 42 --reassign=7 # moves user 42's content to user 7, then deletes 42
Verify
Re-run the user list. Confirm the remaining admins can still log in and that content is attributed correctly.
What could go wrong
Integrations authenticated as the removed user (application passwords, API keys tied to that user) stop working. Scheduled posts by that user may be affected.
Rollback
Downgrading a role is reversible. Deletion is not, except from backup. Downgrade first, wait a week, then delete.
Escalate when
You find admin accounts nobody recognises. Treat that as a possible compromise, not a tidy-up.
Authentication: passwords and multi-factor authentication
Passwords
WordPress stores password hashes, not passwords. Since WordPress 6.8, new hashes use bcrypt; older portable-hash formats are upgraded when the user next logs in. A hash only protects the password if the password is long and unique. The realistic threat is credential stuffing: attackers replay email/password pairs leaked from other services. Password policy should therefore be:
- Unique per site, generated by a password manager, 16+ characters. Length matters more than symbol rules.
- Never sent by email or chat. Share access through the password manager's sharing feature, or create a separate account.
- Changed immediately after a suspected compromise, a departure, or exposure in a breach. Forced periodic rotation of strong unique passwords adds little and encourages weaker patterns.
Multi-factor authentication (MFA)
MFA requires something beyond the password, so a stolen or guessed password is not enough on its own. WordPress core does not include MFA; it is added with a plugin (for example the community "Two Factor" plugin, or the MFA modules in Wordfence, Kadence Security, formerly Solid Security, and similar suites) or enforced by a single sign-on identity provider.
| Method | Strength | Notes |
|---|---|---|
| Passkeys / WebAuthn security keys | Strongest; resists phishing | Bound to the real domain, so a phishing site cannot relay it. Requires plugin support. |
| TOTP authenticator app | Strong | Six-digit codes from an app. Can be phished in real time, but stops credential stuffing. |
| Email codes | Moderate | Only as strong as the mailbox. Useful as a minimum for low-privilege roles. |
| SMS codes | Weak to moderate | SIM-swap risk. Better than nothing; avoid for administrators. |
Require MFA for Administrators, Editors, Shop Managers and any role with access to customer data. Issue backup codes at enrolment and store them in the password manager. Losing a device without backup codes is the most common MFA support ticket.
Verify
Log in from a private window. The second factor must be requested. Test XML-RPC and REST logins too, if your MFA plugin claims to cover them.
What could go wrong
Lock-out after a lost phone; integrations that log in with a password (old mobile apps, XML-RPC clients) break.
Rollback / recovery
Use the backup codes. If none: rename the MFA plugin's folder over SFTP to deactivate it, log in, re-enrol, rename it back and reactivate. Some plugins also offer a WP-CLI reset.
Escalate when
No one has SFTP, panel or WP-CLI access. Then the host must deactivate the plugin.
Sessions and cookies
After login, WordPress sets authentication cookies: wordpress_logged_in_[hash] identifies the user on the front end, and wordpress_sec_[hash] (on HTTPS) or wordpress_[hash] authenticates wp-admin. Each cookie contains the username, an expiry time, a session token and an HMAC signature made with the keys and salts in wp-config.php. The session token is also stored server-side in the user's session_tokens metadata, so a session can be revoked.
- Sessions last 2 days by default, or 14 days with "Remember Me". Plugins can shorten this with the
auth_cookie_expirationfilter; a shorter lifetime for administrators is sensible. - Log out everywhere: Users → Profile → Log Out Everywhere Else revokes one user's other sessions.
wp user session destroy <user> --alldoes the same from the command line. - Log out everyone: changing the keys and salts invalidates every cookie on the site. Do this after a compromise:
wp config shuffle-salts, or paste fresh values from the WordPress.org salt generator. - Over HTTPS, WordPress marks auth cookies
SecureandHttpOnly.FORCE_SSL_ADMINensures the admin is never used over plain HTTP.
A page cache or CDN that ignores the wordpress_logged_in_ cookie can store a page rendered for a logged-in user and serve it to everyone, admin bar and nonces included. Every page-caching layer must bypass requests that carry WordPress login cookies. See the caching conflicts in Chapter 03.
Authorization, nonces, application passwords and API access
Authentication answers "who are you?" Authorization answers "are you allowed to do this?" Broken authorization is the most common flaw class in WordPress plugins: an AJAX action or REST route that checks a user is logged in, or checks a nonce, but never checks the user may perform that action on that object.
What a nonce does and does not do
A WordPress nonce is a token tied to the current user, a named action and a time window (valid for 12–24 hours; despite the name, it can be used more than once). It proves the request came from a page WordPress generated for this user, which defeats cross-site request forgery (CSRF). It does not prove the user is permitted to do the action. Any subscriber can obtain valid nonces for actions exposed on pages they can see. Secure code always does both: check_ajax_referer() / wp_verify_nonce() and current_user_can() for the specific object. Chapter 04 shows this in an upload handler.
The REST API
The REST API (/wp-json/) powers the block editor, many plugins and headless front-ends. Every route declares a permission_callback; public routes return only public data. Two points come up often:
- Do not disable the REST API wholesale. It breaks the block editor, Site Health, WooCommerce admin screens and many plugins. Restrict specific routes if you need to.
- User enumeration through
/wp-json/wp/v2/usersor/?author=1reveals usernames for authors with published posts. Usernames are not secrets. Limiting enumeration reduces brute-force noise, but it is no substitute for MFA and rate limiting.
Application passwords
Application passwords (since WordPress 5.6) let external tools authenticate to the REST API and XML-RPC with HTTP Basic authentication, over HTTPS only, without the user's real password. Each one has a name, can be revoked individually, records its last use and IP, and bypasses interactive MFA. Practice:
- Create them on dedicated service users with the minimum role, not on personal admin accounts.
- Review Users → Profile → Application Passwords periodically and revoke unused ones. Unrecognised entries indicate compromise.
- If no integration needs them, disable the feature with the
wp_is_application_passwords_availablefilter, or through a security plugin. - Some hosts strip the
Authorizationheader. The default WordPress.htaccessincludes a rule to pass it through; on CGI/FastCGI setups without it, application passwords fail with 401.
XML-RPC
xmlrpc.php is the legacy remote API. Its system.multicall method lets one request try hundreds of passwords, and pingbacks have been abused to drive DDoS traffic. If nothing uses it (check for older mobile app publishing, some Jetpack features, and remote-publishing tools), block it at the web server or WAF (Chapter 07). The xmlrpc_enabled filter only disables authenticated methods; it does not stop requests reaching PHP.
Updates: why outdated plugins and themes are dangerous
When a security update is released, the fix becomes public in the changelog and in the code diff. That tells attackers exactly where the flaw is. Exploits for popular plugins regularly appear within hours to days, and automated mass-scanning follows. From that moment every unpatched site is in a race it will eventually lose. An outdated plugin is not "a slightly older version"; it is a published map of how to break into your site.
Update policy
- Core minor/security releases (for example 7.1.1 → 7.1.2) install automatically by default and should stay that way.
- Plugins and themes can auto-update individually (WordPress 5.5 onwards). Enable it for low-risk, well-maintained plugins. For business-critical ones (WooCommerce, page builders, membership, payment gateways), test on staging and update within days, not months.
- Security releases override the normal schedule. When a vulnerability with active exploitation is announced for a plugin you run, update now, or apply a WAF virtual patch until you can.
- WordPress can roll back a failed plugin or theme update (6.3 onwards) and automatic updates that cause a fatal error (6.6 onwards). These are safety nets, not a test plan.
Safe manual update procedure
- Take (or confirm) a fresh backup of files and database.
- Read the changelog: look for "security", "breaking", "requires PHP", database migrations.
- Update on staging; test the critical paths: login, forms, checkout, key templates.
- Update production at a low-traffic time, one major component at a time.
- Clear caches, then retest the same critical paths as a logged-out visitor.
- Watch the PHP error log and uptime monitoring for the next few hours.
Identifying abandoned extensions
An abandoned plugin will not receive a fix when its next vulnerability is found, and some disclosures are published for plugins whose authors never respond. Look for these signals:
- Closed on WordPress.org. The plugin page shows a notice that it "has been closed" and is no longer available for download. Closures happen for security issues, guideline violations or at the author's request. Treat a closure as urgent until you know the reason; vulnerability databases often record it.
- "Not tested with the latest three major releases" warning on the directory page.
- Last updated more than 12 months ago, for anything that handles user input, files, payments or authentication.
- Support forum full of unanswered threads, especially security or PHP-compatibility reports.
- Deprecation notices from the plugin in the PHP log under current PHP versions.
- Vendor website gone, licence server dead, or the repository archived.
- Ownership changes, such as a new author name or a sudden change in what the plugin does. These are not abandonment, but deserve the same scrutiny.
wp plugin list --fields=name,status,version,update_version,auto_update
wp theme list --fields=name,status,version,update_version
Replacing an abandoned plugin is a migration: identify what it actually does on the site (shortcodes, blocks, database tables, cron jobs, redirects), choose a maintained replacement, rehearse on staging, then remove the old plugin and its leftover data.
Evaluating a plugin before installing it
Every plugin adds code that runs with full privileges, attack surface, update burden and conflict potential. Before installing, ask two questions in order: do we need this at all (can core, the theme or an existing plugin do it?), and is this the right implementation? A small, focused plugin from a responsive maintainer is usually safer than a sprawling "all-in-one" suite that enables twenty features you will never use.
Plugin assessment checklist
Your ticks are saved in this browser only. Reset the list before assessing the next plugin.
- Developer reputation. Identifiable author or company with a track record, other well-maintained plugins, and a published security contact or vulnerability disclosure programme.
- Maintenance history. Steady releases over several years; changelog entries that describe real fixes; security issues fixed quickly in the past.
- Update frequency. Updated within the last few months, and keeps pace with major WordPress and PHP releases.
- Support activity. Forum or ticket replies within days; resolved threads; respectful handling of bug reports.
- Compatibility information. "Tested up to" matches the current WordPress release; required PHP version is stated and fits your server; known conflicts are documented.
- Known vulnerabilities. Checked in WPScan, Wordfence Intelligence or Patchstack. Past issues are normal; unpatched ones or a pattern of slow fixes are disqualifying.
- Required permissions. What roles and capabilities it adds, whether it exposes AJAX/REST endpoints to unauthenticated users, and whether it wants to write files or
.htaccess. - External dependencies. Calls to third-party services, licence servers, remote scripts or fonts; what happens when they are down; bundled libraries and how they are updated.
- Data handling. What personal data it stores or sends, and where; retention; export/erase support for privacy requests; whether it cleans up on uninstall.
- Unnecessary functionality. Can unused modules be disabled? Does it overlap with something already installed (a second cache, SEO, security or SMTP plugin)? See Chapter 03.
- Source. Downloaded from WordPress.org or directly from the vendor, never from a "nulled" or reseller site.
- Tested on staging with your theme, key plugins and PHP version, including the front end as a logged-out visitor.
Hosting, file permissions and directory listing
Hosting security
WordPress security sits on top of the hosting account. Use a separate hosting account (or container, or system user) per site where possible, so one infected site cannot write to another. Prefer SFTP or SSH with keys over FTP (FTP sends passwords in plain text). Turn on MFA for the hosting panel, registrar, DNS host and CDN; those accounts can redirect or replace the whole site. Keep PHP on a version that still receives security support.
File permissions and ownership
Unix permissions control which users can read (r), write (w) and execute (x) a file, for the owner, the group and everyone else. What matters is which user the PHP process runs as compared with who owns the files:
| Item | Typical value | Meaning |
|---|---|---|
| Directories | 755 (or 750) | Owner can write; others can enter and list |
| Files | 644 (or 640) | Owner can write; others can read |
wp-config.php | 440, 400 or 600 | Only the owner (and possibly the group) can read it. Check that PHP can still read it after the change. |
| Anything | 777 / 666 | Never. World-writable files let any process on the server modify them. |
On most shared hosting, PHP runs as your account user (suEXEC, PHP-FPM per-user pools or LSAPI), so 644/755 lets WordPress update itself. On some VPS setups, PHP runs as www-data and the files are owned by a deploy user. WordPress then cannot write, and asks for FTP credentials during updates. The fix is correct ownership or group membership, not 777.
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 440 wp-config.php # use 400 or 600 if your host recommends it; confirm the site still loads
Some hosts need different values (for example 750/640 with a shared group), and some files must stay executable (scripts in vendor/bin). Run the commands only inside the WordPress directory, never in a home directory or /. If you are unsure, ask your host what permissions they expect.
Directory listing
If a directory has no index file and directory indexing is enabled, the web server returns a list of its files. In wp-content/uploads/ that can expose private form uploads, exports or backups. Disable listing server-wide (Options -Indexes on Apache, autoindex off on Nginx, which is the default). Chapter 07 has the configuration.
Disable the built-in code editors
define( 'DISALLOW_FILE_EDIT', true ); removes the theme and plugin file editors from wp-admin, so a hijacked admin session cannot paste a backdoor into functions.php with a few clicks. DISALLOW_FILE_MODS goes further and blocks all installs and updates from the dashboard. Use that only when updates are deployed some other way (Git, CI, WP-CLI), because it also blocks security updates from the dashboard.
Protecting configuration and secrets
- Permissions: tighten
wp-config.phpas described above. - Location: WordPress automatically looks one directory above its root for
wp-config.php. Moving it above the web root means a PHP-handler failure cannot expose it as plain text. Only do this when the parent directory is not itself web-accessible and has no other WordPress installation. - Server deny rules: block direct HTTP access to
wp-config.php, dotfiles (.env,.git,.htaccess), and backup or log extensions (Chapter 07). - Keys and salts: unique, random, and rotated after any compromise.
- Version control: never commit
wp-config.phpwith credentials. Use environment variables or an untracked local config file. - Leftover copies:
wp-config.php.bak,wp-config.old,wp-config.php~orwp-config.php.saveare served as plain text because they do not end in.php. Search for them and delete them. - Debug output:
WP_DEBUG_DISPLAYmust be false on production. Displayed errors reveal paths and sometimes queries.
define( 'DISALLOW_FILE_EDIT', true ); // no theme/plugin editors in wp-admin
define( 'FORCE_SSL_ADMIN', true ); // admin and logins only over HTTPS
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_DISPLAY', false ); // never show errors to visitors
define( 'WP_ENVIRONMENT_TYPE', 'production' );
define( 'WP_AUTO_UPDATE_CORE', 'minor' ); // keep security releases automatic (default)
// define( 'DISALLOW_FILE_MODS', true ); // only if updates are deployed by other means
HTTPS enforcement and security headers
HTTPS should be enforced in four places, which must agree with each other: the CDN or proxy, a web-server redirect, the WordPress URLs (siteurl and home starting with https://), and the content itself (no hard-coded http:// asset URLs, which cause mixed content). Set the redirect in exactly one place where possible. Redirects at two layers that disagree about the scheme are the classic cause of "too many redirects".
Security headers tell the browser to apply extra protections:
| Header | Example value | Protects against | What it can break |
|---|---|---|---|
Strict-Transport-Security | max-age=31536000; includeSubDomains | Downgrade to HTTP, cookie theft on hostile networks | Any subdomain without valid HTTPS becomes unreachable for the max-age period. Start with a short max-age. Only add preload deliberately; it is hard to undo. |
X-Content-Type-Options | nosniff | Browsers interpreting an upload as HTML or script | Rarely anything; mislabelled files may stop working |
X-Frame-Options / CSP frame-ancestors | SAMEORIGIN / frame-ancestors 'self' | Clickjacking | Legitimate embedding of your site elsewhere; some page-builder previews |
Referrer-Policy | strict-origin-when-cross-origin | Leaking full URLs (with tokens) to third parties | Analytics that depend on full referrers |
Permissions-Policy | camera=(), microphone=(), geolocation=() | Embedded scripts using device features | Features that genuinely need them (store locators using geolocation) |
Content-Security-Policy | Site-specific; start with Content-Security-Policy-Report-Only | XSS impact, unexpected third-party scripts | Almost anything if too strict: inline scripts, page builders, analytics, payment widgets. Build it iteratively from reports. |
X-XSS-Protection is obsolete. Modern browsers ignore it, and old values could introduce problems, so omit it or set it to 0. Set each header in one place only: the CDN, the server, or a plugin. Duplicate headers with different values cause unpredictable behaviour (see Chapter 03, Conflicting security headers). Configuration examples are in Chapter 07.
Verify
curl -sI https://example.com/ | grep -iE 'strict|content-security|x-frame|x-content|referrer|permissions'. Check that each header appears once. Then browse the site and the editor with the developer tools Console open.
What could go wrong
Blocked scripts or iframes (CSP, frame options), unreachable subdomains (HSTS), broken payment widgets.
Rollback
Remove the header line and reload the server or purge the CDN. HSTS stays cached in browsers until max-age expires, so you cannot fully roll it back.
Escalate when
Headers must be set at a CDN or server you do not control, or the CSP needs to cover a complex checkout.
Database security in brief
The database holds every user, password hash, order and setting. In brief: use a dedicated database user limited to this site's database; never use root; keep the database server off the public internet (bind to localhost or a private network); use a long random password; keep backups encrypted and off-server; avoid ad-hoc SQL edits on production. Changing the table prefix from wp_ does not replace any of these, because an attacker with SQL injection can read the prefix in one query. The full treatment is in Chapter 08.
Security logging and monitoring
Prevention eventually fails. Logging decides whether you notice in an hour or in six months, and whether you can work out what happened. Useful logs:
- WordPress activity log (from an activity-log plugin such as WP Activity Log or Simple History): logins and failed logins, user creation and role changes, plugin and theme installs, activations and updates, settings changes, content deletion.
- Web server access logs: every request with IP, time, method, path, status and user agent. Essential for working out an attack path, for example POST requests to an unusual PHP file in
uploads. - PHP error log: fatal errors and warnings. Sudden new errors from unknown files are a red flag.
- WAF/CDN logs: blocked requests, challenges, rate-limit events.
- File integrity monitoring: alerts when core, plugin or theme files change outside an update.
- Uptime and certificate monitoring from outside your hosting.
Logs should be stored where a compromised site cannot erase them (off-server or at the host level), retained long enough to cover the time it takes to discover a breach (90 days is a practical minimum), and protected because they contain personal data such as IP addresses and email addresses. Alert on high-value events: new administrator, plugin installed, file changes in core, spikes in failed logins.
Malware monitoring
Malware scanners work at different layers, each with blind spots:
- Server-side scanners (host-provided, ImunifyAV/Imunify360, ClamAV-based tools, Maldet) see every file, including those outside WordPress, and are not disabled when WordPress is compromised.
- Plugin-based scanners (Wordfence, MalCare, Kadence Security and similar) understand WordPress context and compare against known-good files, but run inside the environment they are scanning.
- External scanners (Sucuri SiteCheck and similar) only see what a visitor sees: injected spam, redirects, blocklist status.
- Integrity checks:
wp core verify-checksumsandwp plugin verify-checksums --allcompare files against WordPress.org. Premium plugins are not covered.
Signs of compromise: unknown admin users; PHP files in uploads; unfamiliar mu-plugins; obfuscated code (eval(base64_decode(, gzinflate, long encoded strings); redirects that only affect mobile visitors or visitors arriving from search engines; Japanese or pharmaceutical spam pages in search results; outgoing spam; a Google Search Console security warning. Some malware hides from logged-in administrators, so check as a logged-out visitor, from a phone and from a search-engine result. The response procedure is in Chapter 11.
Vulnerability management
Vulnerability management is a continuous loop: know what you run, know when it is vulnerable, fix it within a set time, and confirm the fix.
- Inventory. List every plugin, theme, core version, PHP version and server component for each site. WP-CLI output or a management dashboard is enough.
- Intelligence. Subscribe to a vulnerability feed that matches your inventory: WPScan, Wordfence Intelligence, Patchstack, or a security plugin or host service built on one of them. CVE identifiers link entries across databases.
- Triage. Severity scores (CVSS) are a starting point. What matters is exploitability in your configuration. Is the vulnerable feature enabled? Does it need authentication, and do untrusted users have accounts? Is it being exploited in the wild?
- Remediate within defined times, for example: actively exploited or unauthenticated critical, within 24 hours; high, within 7 days; medium, within 30 days. If no patch exists, disable the plugin, remove the feature, or apply a WAF virtual patch.
- Verify the installed version, and check logs for signs the flaw was exploited before you patched. Patching does not remove a backdoor already planted.
Security priority matrix
Work through these in order. Each tier assumes the one above it is done.
| Priority | Improvement | Why at this priority | Effort |
|---|---|---|---|
| Critical | Restorable off-site backups with a tested restore | Recovers from every other failure, including ransomware and bad updates | Low–medium |
| Critical | Update core, plugins, themes; remove abandoned or nulled extensions | The leading cause of compromise | Low, ongoing |
| Critical | Unique strong passwords and MFA for all privileged accounts (WordPress, hosting, registrar, DNS, CDN, email) | Stops credential stuffing and most account takeover | Low |
| Critical | Remove unknown or unnecessary administrators | Each admin is equivalent to server code execution | Low |
| Critical | Supported PHP version; HTTPS everywhere | Unsupported PHP receives no security fixes | Medium |
| High | Vulnerability monitoring with defined patch timelines | Closes the window between disclosure and patch | Low |
| High | Block PHP execution in uploads; protect wp-config.php and dotfiles; disable directory listing | Contains file-upload flaws; prevents secret leaks | Low |
| High | Login rate limiting; disable XML-RPC if unused | Reduces brute force and resource exhaustion | Low |
| High | WAF (CDN or host-level preferred) | Blocks mass exploitation, and provides virtual patching | Low–medium |
| High | DISALLOW_FILE_EDIT; correct file permissions; SFTP/SSH keys instead of FTP | Limits what a hijacked session or neighbour can do | Low |
| Medium | Activity logging, file integrity monitoring, uptime/SSL monitoring | Detection and forensics | Low–medium |
| Medium | Security headers (HSTS, nosniff, frame-ancestors, Referrer-Policy) | Defence in depth in the browser | Low |
| Medium | Least-privilege database user; restricted application passwords and API keys | Limits blast radius | Medium |
| Medium | Restrict origin to CDN IP ranges | Prevents WAF bypass | Medium (needs host) |
| Routine | Content-Security-Policy (report-only first) | Strong but costly to maintain on plugin-heavy sites | High |
| Routine | Quarterly access review; salt rotation after staff changes | Hygiene | Low |
| Routine | Cosmetic obscurity (hiding version strings, custom login URL, non-default prefix on new installs) | Reduces noise only; never a substitute for the above | Low |
Rather have someone else keep WordPress healthy?
Our managed hosting and care plans cover updates, backups, security monitoring and fixes like the ones in this handbook, so you can get on with running the business.
See Hosting & Care