WordPress hardening CRS plugin

The WordPress hardening CRS plugin adds WordPress-specific rules to the OWASP Core Rule Set (CRS 4), so the web application firewall stops many attacks on a WordPress site before PHP loads. It is for admins who run WordPress behind ModSecurity on NGINX, Angie or Apache, or behind Coraza, and want rules that know what WordPress requests look like.

The plugin does not repeat what CRS already does. CRS runs libinjection (@detectSQLi and @detectXSS) on every argument. This plugin adds the typed-parameter checks CRS lacks: a WordPress query variable that must be a number is rejected when it is not, and a sort parameter must be a plain column name. Many recent SQL injection and XSS flaws in WordPress plugins sit in exactly those parameters.

→ GitHub  ·  Full guide (every rule explained)  ·  All CRS plugins

⭐ View on GitHub →

Integration testsLintApache + ModSecurity v2nginx + libmodsecurity3WAF security corpus

📖 Deep-dive write-up: WordPress hardening plugin for ModSecurity CRS: every rule explained

What the WordPress hardening CRS plugin blocks

The plugin contains over 100 rules, each with its own SecAction toggle in wordpress-hardening-config.conf. Most protections are enabled by default. The main groups are:

  • Typed query variables: WordPress’s numeric query variables (p, page_id, attachment_id, m, year, paged, cpage and others) must be integers. order= must be asc or desc, and orderby= a bare column name. ORDER BY injection is a common SQL injection class in WordPress plugins, and a typed allowlist is stricter than libinjection, which has documented ORDER BY bypasses.
  • Endpoint lockdown: xmlrpc.php, user enumeration and logins with the literal username admin are blocked by default, as are the wp-admin theme and plugin editor and backup, archive and SQL dump paths. Blocks for the REST API and wp-cron.php are available but off by default.
  • Information leaks and probes: readme.html, license.txt, .user.ini, install.php, wlwmanifest.xml and debug.log; version control and dotfile probes (.env, .git/, .svn/, .htpasswd); wp-config backup copies; PHP stream wrappers in arguments (php://, data://, phar:// and similar).
  • Known CVE signatures: SureTriggers/OttoKit (CVE-2025-3102, CVE-2025-27007), Bricks Builder (CVE-2024-25600) and the CVE-2018-6389 load-scripts DoS, plus old scanner probes for revslider, timthumb, MailPoet, wp-file-manager and Duplicator.
  • GeoIP and IP reputation: an optional country check on wp-login.php and an IP/CIDR blocklist. Both are off by default.
  • Login rate limiting: 5 POST requests to wp-login.php per 60 seconds per client IP, then HTTP 429 (RFC 6585). It lives in a separate optional file and works on Apache only; see the engine note below.
  • BREACH/CRIME tagging: marks compressible requests that carry secrets. The actual fix is in the proxy configuration; see the BREACH guide.
  • Fewer false positives on posts: on front-end permalinks the plugin switches off the CRS PHP data-leakage response rules (953100, 953110, 953120), so a tutorial with PHP code in it is not blocked on the way out.

How it fits into CRS

Like every CRS plugin, it has three rule files. wordpress-hardening-config.conf loads first and holds the toggles, wordpress-hardening-before.conf runs before the CRS rules and wordpress-hardening-after.conf after them. The .data files next to them hold the file, scanner, country, reputation and proxy lists; keep them in the same directory.

The plugin is on as soon as CRS loads it. To turn it off, uncomment rule 9522010 in wordpress-hardening-config.conf, which sets tx.wordpress-hardening-plugin_enabled=0, or remove the plugin from plugins-enabled/. It is meant to run next to the CRS project’s WordPress rule exclusions plugin: that one removes false positives, this one only adds blocks.

Install from the APT package

On Debian and Ubuntu with our repository set up, the modsecurity-crs package already contains this plugin in /etc/modsecurity/crs/plugins-available/wordpress-hardening-plugin/, next to the upstream wordpress-rule-exclusions-plugin. Enable both with a symlink, for example ln -s ../plugins-available/wordpress-hardening-plugin /etc/modsecurity/crs/plugins-enabled/wordpress-hardening-plugin, and the same for the exclusions plugin. The packaged /etc/modsecurity/modsecurity.conf-recommended already includes every enabled plugin’s config, before and after files in the right order around the CRS rules. Then reload the web server.

That file starts in DetectionOnly mode. Leave it there for a while, read the audit log for requests the plugin would block, and only then switch SecRuleEngine to On.

Two files are not loaded automatically, because their names fall outside the CRS loader’s patterns. wordpress-hardening-ip.conf adds client-IP resolution, trusted-proxy handling, private-network exemptions and the IP reputation list; include it after the plugin config files and before the before files. wordpress-hardening-ratelimit.conf adds the login limiter; include it on Apache only, after the before files. Without these files the base rules still run.

Not on Debian or Ubuntu? The source archive of the current GitHub release leaves out the test tree, so it works with the standard CRS plugin install. Need the engine first? See How to install ModSecurity and OWASP CRS on NGINX.

Client-IP handling

With wordpress-hardening-ip.conf loaded, the blocked endpoints, the rate-limit counter, the GeoIP check and the IP reputation list all use one client-IP resolver and one private-IP decision, so every rule sees the same client. Loopback, RFC 1918 and IPv6 ULA addresses are then exempt from the xmlrpc, REST API and wp-cron blocks, so internal cron jobs, monitoring and load balancers still reach them. The other protections apply to every client.

Trusted-proxy pinning is on by default and the proxy list ships empty, so X-Forwarded-For is ignored until you list your own proxies in wordpress-hardening-trusted-proxies.data. List only proxies that overwrite the incoming header. That way a client cannot claim a private address with a forged header to get the exemption.

Engine note: rate limiting

Rate limiting relies on persistent collections (initcol and IP: variables). This works reliably on Apache with mod_security2. libmodsecurity3, the engine behind NGINX and Angie, has long-standing gaps in persistent collections: the counter often never persists, so the limit never triggers even though the rule loads fine. Coraza has no persistent collections and refuses to load the file. On NGINX and Angie, protect /wp-login.php with the server’s own limiter (limit_req zone=…) instead.

Tested engines and supported systems

Each change is tested in CI on Apache with mod_security2, which runs the full regression suite, on NGINX with libmodsecurity3 and on Coraza. The modsecurity-crs package is built for Debian 13 trixie, 12 bookworm and 11 bullseye, and for Ubuntu 26.04 resolute, 24.04 noble and 22.04 jammy, on amd64 and arm64. On Debian 11 arm64 only the engine and the rule set are available, without the NGINX and Angie connector modules.

Related reading