This is the write-up I wish I had before I started deleting security plugins from my WordPress install. On this site the entire hardening layer now lives in exactly two places: one must-use plugin sitting in wp-content/mu-plugins/, and the Caddy config at the edge in front of the container. There is no security plugin in the admin panel, no SEO plugin either, and nothing in the plugin list that a scanner can fingerprint, version-match, or talk into doing something stupid. If you want the broader picture of how this box is put together, my self-hosting security notes cover the rest of the stack — SSH, fail2ban, the firewall layers. This post is specifically about the WordPress application surface and how I got it down to almost nothing.
The plugin surface problem, stated honestly
Every WordPress security plugin is a program that runs with full application privileges, on every request, and accepts input from the internet. That is the whole deal. You install it to reduce risk and you simultaneously add a new thing that can be exploited. The usual counter-argument is that the plugin is maintained by people who think about security full-time, which is true, and that it saves you from writing your own code, which is also true. But it hides a cost that only shows up later: you now have a dependency you did not write, cannot easily audit, and must keep updated forever, and its feature set is decided by a product roadmap rather than by your actual threat model.
For a blog like this one, the threat model is narrow and boring. I am not running a membership site, a store, or a forum. There are no user accounts worth stealing beyond my own, no payment data, no customer records. What I actually need is: stop automated login attempts, stop the endpoints that exist purely to be abused, stop comment spam from ever reaching the database, and stop advertising the exact version of WordPress I am running so that scanners can match me against a CVE list. That is a short list. It does not require a dashboard with forty toggles.
So the decision was to stop treating plugins as the unit of hardening and start treating requests as the unit. Where can a request enter, and what should happen to it? That framing collapses the whole thing into two chokepoints: the application, which decides what WordPress will answer, and the edge, which decides what even reaches the application. Once I had those two layers named, the implementation got much smaller than the pile of plugins it replaced.
Layer one: the mu-plugin
The application-side work lives in a single file, wp-content/mu-plugins/igornews-seo-hardening.php. The mu-plugins directory is the part of WordPress that people forget about, and it is the right home for this for three reasons that matter more than they sound.
- It loads automatically. No activation step, no “plugin was deactivated after an update” surprise, no admin action required after a restore from backup. A must-use plugin is code that is simply part of the site.
- It cannot be switched off from the admin UI. That cuts both ways — if it has a bug, you fix it over SSH or through the mounted volume, not by clicking. But it also means that an attacker who gets into
wp-admincannot quietly disable the hardening by deactivating a plugin, which is exactly what a lot of malware tries to do first. - It adds no discoverable plugin entry. Nothing shows up in the plugin list to be enumerated, version-checked, or matched against a vulnerability feed. The file is just there, doing its job.
Inside that one file I do four things, and I want to be precise about them because the restraint is the point. First, xmlrpc is off. Second, the REST endpoint /wp/v2/users is off. Third, comments are closed. Fourth — and this is the part that makes the file name look strange — the same file emits the site’s meta tags, Open Graph tags, Twitter card tags, and JSON-LD schema.
Yes, the SEO output and the hardening live in the same file. That is deliberate, and I will come back to why.
Why xmlrpc had to die
XML-RPC is a legacy remote-procedure interface. It exists so that old desktop publishing clients and the mobile app can talk to WordPress, and it accepts a single POST body that can contain a batch of method calls. That batching is the problem. It lets an unauthenticated client submit many login attempts inside one HTTP request, which means rate limiting that counts requests — at the edge, in the web server, in a WAF — sees one request instead of a hundred. You can build a password-guessing engine that looks almost idle from the outside.
I do not use a desktop client. I write in the browser. So xmlrpc on this install was pure downside: an authentication endpoint I never call, wrapped in a protocol designed before anyone was thinking about abuse at scale. Turning it off removes the endpoint entirely rather than trying to police it. That is the difference between mitigation and removal, and for a feature I do not use, removal is strictly better.
Why the users endpoint had to die
The REST API is not optional in modern WordPress — the block editor depends on it. But the default surface is wider than the editor needs. /wp/v2/users will happily return a list of accounts, and depending on configuration it can expose login names and author slugs. That is a gift to anyone doing credential stuffing, because the expensive half of that attack is figuring out which usernames exist. Hand someone a list and the attack gets cheaper by an order of magnitude.
This is the kind of endpoint that no plugin toggle describes well: it is not “insecure,” it is convenient for the wrong person. Blocking it costs me nothing because the site has no public author directory and no multi-author workflow that needs it. The rule I applied here is the one I keep coming back to — if a capability exists only to serve a use case I do not have, it is not a feature, it is attack surface with documentation.
Why comments are closed, not moderated
Comment moderation is a filter. A filter has to inspect every submission, decide, and store the ones it is unsure about. That means the comment form stays open, the submission path stays reachable, the database still receives writes from unauthenticated strangers, and I still have a moderation queue to look at. Closing comments does something different: it removes the input path.
I ran the moderation queue for a while. What arrived was almost entirely automated — link drops, generic praise with a URL in the name field, attempts to get something indexed. The genuine comments were rare enough that email and the fediverse cover them. Once I accepted that, the equation flipped: I was paying attention, storage, and a write endpoint for a channel that carried almost no signal. Closing comments deleted the entire category of problem instead of managing it. No spam plugin, no Akismet key, no captcha, no queue.
The SEO half, and why it shares a file
The conventional way to get meta tags, Open Graph, Twitter cards, and JSON-LD schema onto a WordPress site is to install an SEO plugin. The two big ones are enormous: sitemaps, redirects, breadcrumbs, schema builders, a dozen admin screens, and an update stream that ships several times a month. I do not want any of that. I want a title tag, a description, the social preview tags, and a schema block that tells search engines what kind of document this is.
That is a small, static amount of markup. It has no settings UI, no database tables, no cron jobs, and no upgrade path to babysit. It is also, structurally, the same kind of code as “print a header” and “return 403 for this endpoint” — it hooks into the same request lifecycle and emits output. Splitting it into a second file would mean two pieces of code that always ship together, always get edited together, and always have to agree about what page they are rendering.
So they are one file. When I add a post type, I touch one place. When I change how a canonical URL is built, I touch one place. And critically, the SEO code has no third-party dependency to inherit vulnerabilities from — no Yoast, no RankMath, nothing in wp-content/plugins that a scanner can look up by slug and version.
Layer two: Caddy at the edge
The mu-plugin is the application deciding what it will answer. Caddy is the edge deciding what gets asked in the first place, and it is doing four jobs.
HSTS and security headers. Caddy adds the transport security header and the standard hardening headers on every response, so the browser is told to refuse plaintext for this host and to apply the usual restrictions. Doing it at the edge means the headers exist even on responses that never touched PHP — static assets, error pages, redirects. A header set inside WordPress only applies to requests that reached WordPress, which is a smaller set than you think.
Blocking xmlrpc.php with a 403. This is belt and braces on top of the mu-plugin. The application already refuses to serve xmlrpc, but the edge rejects the path before the request is anywhere near PHP. Two independent layers, and I would rather have both: the edge rule costs nothing and does not depend on WordPress loading correctly or on the mu-plugin being present after a botched deploy.
Stripping version-leak headers. By default a stack will tell you what it is. The server header names the server, and application-level headers can name the runtime. That information is not needed by any legitimate client and is exactly what an automated scanner uses to pick which exploit to try. Caddy removes it on the way out, so the response says as little as possible about what is behind it.
The thing I like about this split is that the two layers fail independently. If the container is rebuilt and the mu-plugin is missing, the edge still blocks the worst paths. If the edge config is wrong, the application still refuses xmlrpc, still hides users, still has no comment form. There is no single file whose loss undoes the whole posture.
The gotcha: hardening that breaks quietly
Here is the part that cost me real time, and it is not a bug in either layer — it is a property of the approach. When you remove features instead of configuring them, the failure mode changes shape. A misconfigured plugin usually announces itself: a red notice, a settings page that will not save, an error in a log. A removed endpoint just returns a 403 or an empty result, silently, to whoever asked.
That is fine when the asker is a scanner. It is not fine when the asker is you, or a piece of the site you forgot depended on the thing you deleted. The first time I tightened this down, something that used to populate author information stopped populating it. Nothing crashed. No error appeared anywhere I was looking. The page simply rendered with a gap where data used to be, and I spent a while assuming the problem was in the template or the cache before it occurred to me that the request behind that gap was hitting the endpoint I had switched off.
The lesson I took from it is a discipline, not a code change: when I disable a surface, I write down what used to consume it. The endpoint list is short, so the check is short — who calls /wp/v2/users? Who calls xmlrpc? Who submits a comment? If the answer is “nothing I control,” the removal is free. If the answer is “the block editor, on this one screen,” then I do not disable it globally; I disable it for the requests that do not need it and leave the editor alone. Blanket rules are easy to write and easy to regret.
The second half of the gotcha is verification. You cannot confirm a 403 by reading your own config file. You confirm it by making the request and looking at the status code that comes back. Same for the headers: the only evidence that HSTS is on the response is the response. I now treat “did the request come back the way I intended” as the definition of done, rather than “did I save the file.” It sounds obvious written down. It is not obvious at the moment you are tired and the config looks right.
What I would do differently
Test the removals before the rewrite. I did the SEO work and the hardening work in one pass, which meant that when something broke I had two candidate causes. Splitting it — first prove the meta tags render, then remove endpoints one at a time — would have made the diagnosis a single step instead of an elimination game.
Write the consumer list first. Before touching anything, list what calls each surface. It takes a few minutes and it converts “I hope nothing used that” into a fact.
Keep the edge rules minimal and ordered. The edge is the most powerful layer and the easiest place to create a rule that shadows another. Every rule I add there, I check by requesting the path it is supposed to affect and one path next to it that it is not.
Do not chase completeness. The temptation with a hardening file is to keep adding. Every addition is another thing that can break the site in a way nobody notices. The list of four jobs in the mu-plugin is not a starting point I intend to grow from. It is the list.
The checklist I actually run
- Request
xmlrpc.php. Expect a 403 from the edge, and confirm the application agrees by checking the response when the edge rule is out of the picture in a test. - Request
/wp/v2/users. Expect it to be refused, not to return an empty-but-valid author list. - Load a post and check the comment form is absent, not merely closed to new submissions by a setting.
- Read the response headers on a static asset. HSTS and the security headers should be present even though PHP never ran.
- Read the same headers for anything that names the server or the runtime version. There should be nothing useful to a scanner.
- View source on a post and confirm the meta, Open Graph, Twitter, and JSON-LD blocks are present and describe that post.
- Look at the plugin list. It should contain nothing whose job is security or SEO.
The outcome
The site now has one file of application logic and one edge config standing between the internet and WordPress. There is no Yoast, no RankMath, no security suite, no spam filter, no captcha, and no update treadmill for any of it. The plugin surface I have to trust is empty, which means the answer to “what did you install that could be exploited” is “nothing.”
It also means the site is boring to maintain, and that is the actual goal. Nothing in this setup phones home for a license, shows a dashboard, or asks me to confirm a settings migration. The hardening is a property of the deployment rather than a checklist I have to remember to run — and the only thing I have to be careful about is the one thing that is genuinely mine: knowing what I removed, and making the request afterward to prove it stayed removed.
Related
- systemctl –user Fails as Root: “No Medium Found”
- fail2ban Bans That Quietly Do Nothing on Docker Ports
- Your API Rate Limit Is Per Base, Not Per Key
- SSH Brute-Force to Crypto Miner: Hardening a VPS the Hard Way
- Fixing ECONNRESET on a Self-Hosted HTTP Bridge
Guides & explainers
Filed under: Cybersecurity, Automation, fail2ban, Security Hardening, Self-Hosting, SSH