Ahosting Logo
Knowledge Base

ModSecurity: What It Blocks and Why It Blocks You

A 403 with nothing in the application logDoes one specific action fail consistently while everything else works?YesProbably ModSecuritythe request never reached your application, so itslog has nothing to showNoLook elsewhere firstpermissions, a redirect rule, or the applicationown access controlThe rule that fired is in the ModSecurity audit log, and the fix belongs on that rule, not on the firewall.

ModSecurity is a web application firewall running in front of your site. It inspects each request against a rule set and blocks anything matching a known attack pattern, and because it works on patterns rather than intent, it occasionally blocks you.

Most people meet it that way: something in the admin area suddenly returns a 403 for no apparent reason.

What it actually protects against

Requests carrying the shape of an injection attempt, a traversal attack, or a known exploit. It sees these before your application does, so a vulnerability reachable by an unauthenticated request can be stopped before the code that would be exploited runs at all.

That is genuinely valuable in the window between a vulnerability becoming public and you applying the patch, which is measured in hours for popular software.

Why it blocks legitimate requests

The rules match patterns in the request, and legitimate content sometimes contains those patterns.

Common false positives: editing a page whose content includes SQL-looking text or code samples, saving a theme customisation containing angle brackets, a plugin sending an unusual request format, and file managers or backup tools that post large structured payloads.

None of these are attacks. They look like attacks to a rule that can only see the request.

Recognising a ModSecurity block

A 403 rather than an error page from your application. The request never reaches your code, so nothing appears in the application's own log, which is what makes it confusing.

The tell is that a specific action fails consistently while the rest of the site works. Saving one particular page fails; saving other pages is fine. That pattern is almost always a rule matching something in that page's content.

Finding which rule

In cPanel, ModSecurity Tools shows recent hits with the rule ID and what triggered it. That is the fastest route from "something is broken" to "rule 942100 matched the content of this field".

Reproduce the failure, then look at the most recent entries. Matching by time is much easier than reading a long log.

Disabling one rule, not all of them

The tools screen lets you disable a specific rule ID. That is the correct response to a confirmed false positive.

Turning ModSecurity off entirely to fix one page removes the protection from every page. It is the equivalent of disabling the smoke alarm because it went off while cooking: understandable in the moment and a poor permanent arrangement.

If a rule fires repeatedly on ordinary work, disable that rule and note why. If several rules fire on one plugin, that plugin is doing something unusual and is worth looking at rather than working around.

What it does not do

Patch anything. An outdated plugin is still vulnerable; ModSecurity may block the common exploit shape and will not block a variant. Updates remain the actual defence, securing WordPress puts them first for that reason.

Stop an attacker with valid credentials. A request from a logged-in administrator looks legitimate because it is.

Protect against everything. It matches known patterns. Something novel passes through.

It costs a little on every request

Each request is inspected before being served, which is real work. On a normal site it is not noticeable.

Where it can matter is a site under heavy automated traffic, since every one of those requests is inspected too. That is a reason to reduce the traffic rather than to disable the inspection.

When to ask rather than configure

On shared hosting the rule set is server-wide and you control only whether specific rules apply to your account.

If a rule is blocking something legitimate and you cannot identify it, a support ticket with the exact time of the failure and the URL is answered quickly. The server-side log has the detail. That is faster than guessing, and considerably better than turning the whole thing off.

For blocking specific addresses yourself rather than relying on the rules, IP Blocker and Leech Protection in cPanel walks through the tools.

Reproduce the block before changing anything

A report that something is blocked is much easier to act on once you have triggered it yourself.

curl -s -o /dev/null -w '%{http_code}\n' -X POST -d "test=<script>" https://example.com/form
grep -i 'modsec' ~/logs/example.com.error.log | tail -5
date

Note the exact time, then read the log for that moment. The entry names the rule, the part of the request that matched and the value that triggered it, which together identify what to do.

Without a reproduction, the investigation depends on somebody else describing what they did, and the description is rarely precise enough to find the matching entry among the rest.

The false positives cluster in predictable places

Rules match patterns, and certain ordinary content resembles those patterns closely.

Text containing code examples, a password with unusual punctuation, an address with a quote in it, a file upload containing anything binary, and any form where somebody pastes a fragment of a document are the recurring cases.

awk '$9 == 403 {print $7}' ~/logs/example.com | sort | uniq -c | sort -rn | head

Reading which addresses produce refusals shows whether they concentrate on one form. A single form producing most of them is a rule interacting with that form's content rather than an attack.

Ask rather than disabling when it is not yours

On shared hosting the configuration belongs to the server, and the useful request is specific rather than general.

Send the rule identifier, the exact time, the address requested and what the visitor was doing. A request naming a rule can be acted on for one account; a request to turn the protection off usually cannot be granted at all.

Disabling everything for a domain because one rule is inconvenient removes protection from every request to that domain. The proportionate answer is one rule, for one path, with a note of why. WHM Security Center covers what a reseller can reach.