Skip to content

Correlating ModSecurity audit log entries with customer-side errors

When a customer reports "site is broken" but the server is up, the answer is often in modsec_audit.log. Here is how to correlate their timestamp to a rule ID.

A customer says “I can’t save anything in WordPress admin.” The server is up, the disk has space, the database is responsive. The ModSecurity audit log usually has the answer — a vendor rule that fires on a specific POST. Correlating their ‘when did this happen’ to the right block in the log is the diagnostic skill that turns this from a 90-minute investigation into a 5-minute fix.

What’s happening

Every 403, 406, or unexpected redirect from a page that worked yesterday is a candidate for ModSecurity false-positive correlation. The audit log captures the matching rule, the request body, the source IP, and the response. The trick is finding the right entry — modsec_audit.log on a busy server is large, and the customer’s timestamp may be approximate.

How to verify

date -u
ls -lh /usr/local/apache/logs/modsec_audit.log
grep -B2 -A20 "$(date -u +'%d/%b/%Y:%H')" /usr/local/apache/logs/modsec_audit.log | head -80
grep -B2 -A20 "<customer-IP>" /usr/local/apache/logs/modsec_audit.log | head -80
awk -v ts="$(date -d 'today 14:00' -u +'%d/%b/%Y:%H:%M')" '$0 ~ ts' /usr/local/apache/logs/modsec_audit.log | head

date -u confirms server time; customers usually give you local time. Time-zone confusion explains half the “I can’t find it” cases.

The fix

  1. Get a precise time and source IP from the customer. Browser DevTools > Network tab shows the failing request and the time stamp to the second.
  2. Convert their timestamp to UTC if their browser is in a different time zone than the server’s modsec_audit.log. Cross-check with date -u.
  3. Pull the audit block by IP and time: the grep above. The right block has the customer’s source IP and a timestamp within 30 seconds of their report.
  4. Identify the rule ID: every block has [id "942100"] (or similar) lines listing the rules that fired. Note the highest-severity one — it is usually the one that produced the response.
  5. Pull the rule definition: whmapi1 modsec_get_rule rule_id=942100 vendor_id=OWASP3 returns the rule text and intended behavior. Read it.
  6. Decide: add a per-location exclusion in WHM > ModSecurity Tools, or push back to the application owner if the rule is firing on a genuine attack pattern.
  7. Tell the customer what you did. “Adjusted a security rule that was blocking your image uploads” is honest and short.

Stack Harbor handles modsec false-positive correlation under cPanel/WHM management.