- 25+ Projects Delivered • 5 Years Experience • UK, USA & Pakistan Clients • Free SEO Audits - 25+ Projects Delivered • 5 Years Experience • UK, USA & Pakistan Clients • Free SEO Audits 

- 25+ Projects Delivered • 5 Years Experience • UK, USA & Pakistan Clients • Free SEO Audits - 25+ Projects Delivered • 5 Years Experience • UK, USA & Pakistan Clients • Free SEO Audits 

Back issues Writing

WordPress Login Hardening: What Each Change Actually Stops

I put five login changes on a stock WordPress install and measured each one. XML-RPC still answered 80 methods after the usual one-line filter.

Topics

The first thing I open on a new install is not the theme. It is the server access log sorted by request count, and the top two lines are almost always wp-login.php and xmlrpc.php, both hit by addresses I have never seen.

A client sent me one of those logs last month: overnight, one POST to the login form after another, each with a different username from a different address. Nothing was broken, nobody had the password, and the log was the whole story.

Short answer

Four changes close almost all of it, in this order: block xmlrpc.php at the server, close the author lists, count failed logins per address and answer the seventh with a 429, and send one login error message instead of two. Headers and wp-config are the fifth, and they change what a login can do after it succeeds. On a stock install I measured, the one-line XML-RPC filter that gets quoted everywhere left all 80 methods answering.

I did not want to argue from memory, so I built the install and measured it: one WordPress 6.7.2 container, PHP 8.3.20, Apache 2.4.62, one administrator, one post, pretty permalinks on. blog-pipeline/tools/measure_login.py hits the login surface and writes blog-pipeline/data/login_lab.json, and every number below is read from that file when this post is built. One load per check, one address, my own machine, so the counts are counts and not rates.

The lab runs 6.7.2 and the sites I maintain run newer core. Run the script on your own install before you trust a method count one major version ahead.

The two doors the bots use

WordPress ships a login form and an XML-RPC endpoint, and both accept a username and password over the public internet. The WordPress handbook on brute force is direct about the second one: xmlrpc.php is a frequent target, especially the system.multicall method, and if you do not use XML-RPC you should disable it.

The same page says WordPress core does not include two-factor authentication, and that is the single most important sentence in it. Everything below is mitigation. The thing that stops a stolen password is a second factor, and you have to add it.

On the untouched install, ten failed logins from one address took 4.39 seconds and all ten came back HTTP 200. Nothing slowed, counted or refused them, which is the shape of the problem: nothing in core slows a wordlist.

The one-line XML-RPC fix does not close the door

The advice you will find in a hundred forum posts is this line in a plugin or a mu-plugin:

add_filter( 'xmlrpc_enabled', '__return_false' );

I applied exactly that and then asked the endpoint what methods it had. system.listMethods came back with 80 methods, system.multicall answered 200, demo.sayHello answered 200, and pingback.ping answered with a parameter fault, which means the method ran. The filter in core only sets a flag that is checked inside a handful of authenticated methods. The front door stays open and it still lists its own rooms.

That is not a small detail. system.multicall is the method that lets one HTTP request carry hundreds of username and password pairs, which is the whole reason the handbook names it. Leaving it answering means the block you thought you applied is a block on a different door.

What actually closes it is the web server, before PHP runs. On Apache:

<Files "xmlrpc.php">
  Require all denied
</Files>

I put that in .htaccess above the WordPress block, because WordPress rewrites everything between its own markers. After the change, both a GET and a POST to that path returned 403 and system.listMethods returned 0 methods. Nginx needs its own rule, and the handbook gives examples for Apache, Nginx, Caddy and IIS, so use the one that matches your host.

01Block xmlrpc.php at the serverThe filter leaves 80 methods open02Close the author listsREST and ?author= both name accounts03Count failures per addressTen tries in 4.4 s became six04Send one login errorTwo messages name the real user05Headers, config, permissionsPHP version and file editing go last
01Block xmlrpc.php at the serverThe filter leaves 80 methods open02Close the author listsREST and ?author= both name accounts03Count failures per addressTen tries in 4.4 s became six04Send one login errorTwo messages name the real user05Headers, config, permissionsPHP version and file editing go last
The order I apply the changes in. The note on each line is the count that step moved on the lab install, read before and after with tools/measure_login.py.

What the login form tells an attacker

Two requests to the stock install did different work. One used a username that does not exist, the other used the real administrator name with a wrong password. The form answered with two different sentences: the first said the username “is not registered on this site”, the second said the password “is incorrect”.

A script can send a list of names and keep the ones answered by the second message. That is a username harvest, and it costs nothing because neither request needed to succeed. The OWASP authentication cheat sheet is blunt about the fix: respond in a generic manner, the same HTTP and the same text, whether the username exists, the account is locked or the password is wrong.

WordPress gives you a filter for that, and it is three lines:

add_filter( 'login_errors', function () {
    return '<strong>Error:</strong> That username or password is not correct.';
} );

After it, the same two probes produced the same sentence, which the script records as same_text: true. The form still tells a person what happened. It stops telling a machine which half of the guess was right.

The account list leaks two other ways, and both are cheaper to close than the plugin people install for it. /wp-json/wp/v2/users returned 1 author record, and /?author=1 answered 301 with a Location header pointing at /author/labadmin/. Removing the users route for logged-out requests and sending the author query var home closed both: 404 on the route, 302 to the home page on the scan, and /wp-json/wp/v2/posts still 200.

The seventh attempt

Rate limiting is the change most people skip, and it is the one the log from my client was asking for. On the stock install, 10 failed logins from one address took 4.39 seconds and none of them was slowed, counted or refused.

I added a counter keyed to the address in a transient with a fifteen minute window. Six failures are allowed. The seventh POST came back 429 with Retry-After: 900, and after that the login page itself stopped rendering for that address, because the check runs before the form is built. Measured on the same install, same script.

Now the part I have to print because it cuts against my own fix. OWASP recommends attaching the failed-login counter to the account rather than the source address, since a botnet has thousands of addresses and a per-IP limit is easy to walk around. That is true, and a per-account lockout on WordPress has its own problem: anybody who knows your username can lock you out of your own site with six requests.

So I split the job. The account gets a second factor, the only control that survives a correct password. The address gets a counter, which on the lab install cut one address from unlimited attempts to six in fifteen minutes.

The WordPress handbook makes the same point about where the counter lives: a plugin that throttles inside PHP still runs PHP, so a flood costs you the resources you were trying to protect. Edge rules and the web server drop the request before WordPress loads.

The second install I maintain sits behind Cloudflare, and its /wp-login.php answered 1,112 bytes of “Checking your browser” without serving the form, against 8,200 bytes of real login form on a host without that layer. A page that returns a challenge cannot be enumerated by a script that does not run JavaScript.

The five changes, with what each one moved

Five changes, each measured on the same container before and after, in the order I apply them:

StageChangeMeasured effect
1Deny xmlrpc.php at the web serverGET and POST went from 405 and 200 to 403; methods answering fell from 80 to 0
2Close REST users and author archives to logged-out requestsUsers route 200 to 404; author scan 301 to 302 to the home page
3Count failures per address, answer the seventh10 attempts with no limit became six allowed then 429 with Retry-After 900
4One login error for every failureTwo message variants became one, so the probe cannot tell a real username from an invented one
5Headers, DISALLOW_FILE_EDIT, wp-config at 6401 of 3 security headers became 3 of 3, and the PHP version header is gone
STOCKHARDENEDXML-RPC methods800Authors listed10Login errors2 kinds1 kindAttempts allowed10 of 106 then 429PHP version sentyesnoSecurity headers1 of 33 of 3
XML-RPC METHODSStock: 80Hardened: 0AUTHORS LISTEDStock: 1Hardened: 0LOGIN ERRORSStock: 2 kindsHardened: 1 kindATTEMPTS ALLOWEDStock: 10 of 10Hardened: 6 then 429PHP VERSION SENTStock: yesHardened: noSECURITY HEADERSStock: 1 of 3Hardened: 3 of 3
One WordPress 6.7.2 container, one user, one post. Each cell measured with tools/measure_login.py, once untouched and once after the five changes, 19 Nov 2026.

Rows 2 and 5 are the ones people argue about. Row 2 does not stop a brute force, it stops the recon that makes one cheap, and on a site with one author it retires a set of pages nobody wanted indexed. Row 5 changes what a login that succeeds can do next.

Files, config and headers

The stock login page sent PHP/8.3.20 in its headers, 4,413 bytes of form and 1 of the three security headers I check. After the last stage it sent 3 of 3 and no version string.

That stage failed silently the first time. I wrote the header block inside <IfModule mod_headers.c> and nothing changed, because the Debian Apache image does not load mod_headers: no error, no log line. apache2ctl -M showed rewrite loaded and headers missing. After a2enmod headers, the same file sent nosniff, a referrer policy and HSTS.

Two wp-config changes go with it. chmod 640 wp-config.php after confirming the owner can still read it, and define( 'DISALLOW_FILE_EDIT', true );, which the hardening page recommends because the dashboard file editor is the first thing an attacker opens after a successful login. The same page gives the file permission scheme I use: 755 on directories, 644 on files, with wp-content the only tree the web server needs to write.

I checked the constant and the mode rather than assuming: DISALLOW_FILE_EDIT=true and 640 www-data from the container.

What a breach looks like in the log

Three log lines matter: POSTs to wp-login.php that return 200 and repeat from one address, any POST at all to xmlrpc.php, and requests for /wp-json/wp/v2/users that return a list rather than a 401.

On the install side the marks are quieter. A new administrator account you did not create, a plugin nobody installed, a theme file newer than your last deploy, a cron event you cannot account for, a password changed without a reset email.

The log is also how you learn the timeline later. With no baseline, an entry from three weeks ago reads like this morning’s, which is what the monthly maintenance pass exists to prevent.

What I would not do

  • Change the login URL and stop there. The handbook calls obscuring the login URL what it is: a noise reducer that should not be the only defence.

  • Put basic auth on all of wp-admin. The same page warns it breaks wp-admin/admin-ajax.php, and on a site with a form plugin that is a broken site.

  • Rely on one plugin’s lockout counter as the only control. It runs in PHP, shares the address space with the attack, and is the first thing a host disables under load.

  • Block the login page by user agent. Half the bots send a real Chrome string and some of your clients use something unusual.

Where I would start tomorrow

Do the server block for xmlrpc.php first: it is a file edit and a reload, and it removes a surface of 80 methods in one step. Then the two filters for the author lists, then the counter, then the error message. Add a second factor the same week, and enable it on a second account before the only administrator.

If you are choosing plugins for the rest of the site, the ones I actually install is the short list, and how to make WordPress fast without a pile of plugins is the other half of the same argument. Before any of that, a backup you have restored is worth more than every rule on this page, because it is the only control that helps after a login succeeds.

The login form is the one page a stranger is invited to use. Every change above narrows that invitation without making it harder for you to get in.

Request

Got a site that should be doing more?

Send me the address and one sentence about what you sell. I will tell you what I would fix first, and whether it is worth fixing at all.

Start a project Free site audit