WordPress Security Hardening

If you would rather have this handled for you, our WordPress security service takes care of this end to end. Most WordPress security guides end at “install a security plugin.” That is useful but incomplete. A security plugin adds a detection layer; it is not a hardening layer. The hardening happens before the plugin even runs, at the server and application level, and it is what separates a site that blocks an attack from one that needs cleaning up after one.

This guide covers WordPress security hardening properly: ten concrete steps that go beyond installing a plugin, plus why each one matters and how to apply it. Applied together, they turn an easy target into a hard one.

Why Hardening Matters More Than a Plugin

A plugin can alert you that an attack is happening. Hardening reduces the chance the attack succeeds in the first place. The two work together, but hardening is the foundation.

Most successful WordPress attacks are automated and opportunistic. They scan millions of sites for any known weakness. Closing those weaknesses in advance is far cheaper than cleaning up afterwards.

Hardening also limits the damage when something does get through. If a vulnerable plugin is exploited on a hardened site, the attacker finds a locked file editor, no writable core files, no PHP execution in the uploads folder and an alert already on its way to you. That is the difference between a contained incident and a full rebuild.

The 10 WordPress Security Hardening Steps

1. Disable XML-RPC if You Do Not Use It

XML-RPC is a legacy API that attackers use for brute-force amplification, where one request can try hundreds of password combinations. If nothing on your site needs it, disable it at the application or server level.

At the application level, a one-line filter in a small must-use plugin does it: add_filter( 'xmlrpc_enabled', '__return_false' );. Blocking requests to xmlrpc.php at the web server or firewall is stronger, because the request never reaches PHP. Before you switch it off, check whether anything still depends on it, such as an older mobile app workflow, a remote publishing tool or a plugin feature that uses it for connections. The modern REST API with application passwords covers most of those use cases.

2. Enforce Strong Passwords and 2FA

Brute force is the most common attack vector against WordPress. Require strong, unique passwords and two-factor authentication for every editor-level account and above. Our guide on two-factor authentication explains how.

While you are in the user list, avoid an account called “admin”, make sure display names do not reveal login usernames, and confirm every administrator is a real, current person.

3. Limit Login Attempts

Three failed logins should trigger a temporary block. Blocking at the server level is even more effective than a plugin, because it stops the attacker before WordPress loads. See our guide on WordPress login security for more.

4. Move wp-config.php Above the Webroot

WordPress automatically looks for wp-config.php one directory up. Moving it there means an attacker who exploits a path traversal flaw cannot easily reach your most sensitive configuration file.

This works when WordPress is installed in the root of your web directory and the folder above is not itself another WordPress install. If your host does not allow files outside the webroot, leave the file where it is and protect it with strict permissions and a server rule that denies direct access to it.

5. Set Correct File Permissions

Directories at 755, files at 644, and wp-config.php at 600. Never use 777 on anything, as it grants world-write access and is a malware foothold waiting to happen.

On a server with shell access, you can reset the defaults from the WordPress root with find . -type d -exec chmod 755 {} \; and find . -type f -exec chmod 644 {} \;, then tighten wp-config.php separately. The right values depend on how your server runs PHP and which user owns the files, so check the WordPress file permissions documentation or ask your host before going stricter.

6. Use a Web Application Firewall

A firewall blocks the most common exploit patterns before they reach your server. Combined with a plugin-level firewall, you get two layers of protection, as explained in our guide on the web application firewall.

7. Keep PHP Current

Old PHP versions no longer receive security patches. Running a current version improves both security and performance. Test in staging first, since some older plugins lag behind. Our guide on your PHP version covers this.

The PHP project publishes the support status of every branch on its supported versions page. If your branch is listed as end of life, it no longer gets security fixes, and moving off it should be on this month’s list, not next year’s.

8. Disable the File Editor in wp-admin

Disabling the dashboard file editor means that even if an attacker gains admin access, they cannot inject malicious code directly through the interface.

Add define( 'DISALLOW_FILE_EDIT', true ); to wp-config.php, above the line that says to stop editing. If you deploy code through Git or SFTP and never install plugins from the dashboard, DISALLOW_FILE_MODS goes further and also blocks plugin and theme installs and updates from wp-admin. Only use it if you have another way to apply updates promptly. Both constants are described in the wp-config.php reference.

9. Monitor for File Changes

A file integrity monitor alerts you when core WordPress files change unexpectedly, a reliable indicator of compromise. Configure alerts to reach an email you actually check.

If you have WP-CLI, wp core verify-checksums compares your core files against the official checksums from WordPress.org, and wp plugin verify-checksums --all does the same for plugins hosted in the WordPress.org directory. Running both on a schedule is a cheap, reliable early warning.

10. Run Regular, Automated Malware Scans

Daily automated scans with alerts beat manual quarterly checks. Malware often sits dormant for weeks before activating, so the sooner you catch it, the simpler the cleanup. Our guide on malware removal covers what to do if you find something.

Extra Hardening Worth Doing

The ten steps above cover the essentials. These additional measures close gaps that automated attacks also look for, and most take only a few minutes.

  • Block PHP execution in uploads. The uploads folder should only hold media. On Apache, an .htaccess file in wp-content/uploads with a rule that denies access to files ending in .php stops a dropped web shell from running. On Nginx, add an equivalent location block.
  • Rotate the security keys and salts. Replacing the keys in wp-config.php logs every user out and invalidates stolen session cookies. Do it after any suspected breach or staff change. wp config shuffle-salts handles it in one command.
  • Delete what you do not use. Deactivated plugins and old themes still sit on disk and can still be exploited. Keep one default theme as a fallback and remove the rest.
  • Apply least privilege. Give writers the Author or Editor role, not Administrator, and remove accounts for former staff and freelancers on the day they leave.
  • Turn off debug output in production. Keep WP_DEBUG_DISPLAY false on the live site so errors never print file paths to visitors.
  • Send security headers. HTTPS everywhere plus headers such as HSTS, X-Content-Type-Options and a sensible Content Security Policy reduce the impact of injected scripts.

Common Hardening Mistakes

Hardening done badly can give you false confidence or take the site down. These are the mistakes we see most often when we audit sites:

  • Stacking two or three security plugins that each add their own firewall and login rules, then fighting conflicts and lockouts.
  • Relying on “security through obscurity”, such as hiding the WordPress version, while leaving plugins months out of date.
  • Making changes directly on the live site without a backup, then finding a server rule has blocked the admin area.
  • Setting file permissions so strict that WordPress can no longer write to the uploads folder or apply updates.
  • Sending security alerts to a shared inbox nobody reads.

Take a fresh backup before each change, apply one change at a time and confirm the front end, login and checkout still work before moving on.

Hardening Is Ongoing, Not One-Time

Security is not a project you finish. New vulnerabilities appear constantly, and a site that was hardened last year can drift out of date as plugins, themes, and configurations change.

Reviewing your hardening measures as part of regular maintenance keeps them effective. The goal is layered, up-to-date defense rather than a single one-off effort.

A simple rhythm works well: updates and scan results weekly, a review of user accounts and installed plugins monthly, and a full pass over this checklist every quarter or after any major site change, such as a migration, a new theme or a new developer joining the project.

Frequently Asked Questions

Is a security plugin enough to protect WordPress?

No. A plugin adds valuable detection and filtering, but real security comes from layers: hardening, strong logins, updates, a firewall, and backups working together.

What is the most important WordPress hardening step?

Strong passwords with two-factor authentication and prompt updates prevent the majority of real-world attacks. If you do nothing else, do those.

Will hardening break my site?

Done carefully and tested in staging, hardening should not break anything. A few steps, such as updating PHP, disabling XML-RPC or tightening file permissions, need testing first because older plugins or integrations may depend on the old behavior.

How often should I review my security setup?

Review it as part of regular maintenance, at least monthly for scans and updates, and quarterly for a fuller audit of accounts, permissions, and configuration.

Can I harden WordPress on shared hosting?

Mostly, yes. wp-config.php constants, user roles, 2FA, removing unused plugins and file permissions are all within your control on shared hosting. Server-level rules, such as blocking xmlrpc.php or PHP in uploads, depend on whether your host allows .htaccess overrides or offers a firewall in its control panel.

Harden Your Site Properly

Real WordPress security lives in the layers beneath the plugin. These ten steps close the weaknesses that automated attacks rely on and give your site a genuinely strong foundation.

For further reading, the official WordPress hardening documentation offers helpful, authoritative guidance.

BlueBotts hardens and monitors client sites as part of every maintenance plan. Request a free site audit or contact our team to secure your site properly.

Filed under
Is your WordPress site as healthy as it should be?

Get a free audit covering security, updates, backups, and performance gaps. Takes 60 seconds to request and costs nothing.

Get your free audit