Skip to content

Reading /usr/local/apache/logs/modsec_audit.log on cPanel

Find the ModSecurity audit log on a cPanel server, pull one whole transaction out of it by unique ID, read the H section for the rule ID and anomaly score, and turn that into a scoped exclusion in WHM that you can prove took effect.

On a cPanel server running EasyApache 4, the ModSecurity audit log is at /usr/local/apache/logs/modsec_audit.log. That path still works because /usr/local/apache is kept as a symlink for compatibility with the old EasyApache 3 layout, and /etc/apache2/logs is itself a symlink into /var/log/apache2 — three names, one file. It holds the complete text of every request ModSecurity considered worth recording: the headers, the body, the response, and a trailer listing every rule that matched. This page is about reading it end to end on a busy server and coming out the other side with a short list of exclusions you can defend, rather than a rule you switched off server-wide because one customer complained.

What you’ll accomplish

  • Confirm which of the three views of ModSecurity activity you are looking at — the audit log, the Apache error log, or WHM’s ModSecurity Tools interface — and know what each one leaves out.
  • Extract a single complete transaction from a multi-gigabyte audit log by its unique ID, in one command, without opening the file in an editor.
  • Read the H section to get the rule ID, the message, the matched variable, the matched data and the anomaly score, and tell the blocking rule apart from the rule that caused the block.
  • Rank rule IDs by hit count per domain and per URI, so tuning starts with the noise instead of with whoever emailed you.
  • Write an exclusion scoped to one domain or one URI, apply it in WHM or a config file, and verify it took effect against a real request.

Prerequisites

  • Root shell access to the server. Nothing below works from a cPanel account; the audit log is readable only by root.
  • cPanel & WHM on EasyApache 4 with the Apache ModSecurity 2.9.x module. ModSecurity 3.x is not what cPanel ships for Apache, and its log format differs.
  • A rule set installed and enabled. The examples use OWASP CRS 3.3.x rule IDs. On CRS 4 the individual rule IDs in the 9xxxxx ranges are largely stable, but the summary rule that reports the score breakdown was renumbered — find it by its msg rather than by the ID quoted here. If CRS is not installed yet, enabling OWASP CRS on cPanel comes first.
  • Paths here are the EA4 defaults. Some servers relocate the log, and some use concurrent logging, where transactions land in a directory tree instead of one file. Step 1 tells you which you have.
  • A graceful Apache restart at the end. No maintenance window needed, but plan for the reload.

How it works

ModSecurity is an Apache module, so it sees a request after Apache has parsed it and before the PHP handler runs. It evaluates rules in phases: phase 1 on the request headers, phase 2 once the request body has been read. The OWASP Core Rule Set does not block on a single match. Each rule that fires adds points to a running counter — 5 for a rule tagged CRITICAL, 4 for ERROR, 3 for WARNING, 2 for NOTICE — and only at the end of phase 2 does rule 949110 compare the total against the inbound threshold, which defaults to 5.

Flow of one request through Apache and ModSecurity on a cPanel server, showing CRS rules adding to an anomaly score, rule 949110 comparing it to the threshold, and the different logs a blocked request and a passed request each land in

This is the single most important thing to understand before you touch a config file. When a customer’s form breaks, the log shows two rules: 942100 matched the payload, and 949110 denied the request. 949110 is the one holding the gun, and it is also the one you must never exclude — removing it does not stop the false positive, it stops all anomaly-based blocking on the server. The rule you exclude is the one that put the points on the board.

The two logs are also not equivalent. A blocked request writes a one-line summary to /etc/apache2/logs/error_log carrying the rule ID, hostname, URI and unique_id, and a full multi-part transaction to the audit log. A request that matched rules but still returned 200 usually appears only in the error log, because cPanel’s default SecAuditEngine RelevantOnly combined with SecAuditLogRelevantStatus records a full transaction only when the response status matches. That asymmetry is why the error log is the better place to search and the audit log is the better place to read.

WHM’s ModSecurity Tools interface is the third view. Security Center → ModSecurity Tools → Hit List is a paginated table of recent hits with the raw log text behind each row — faster than the shell when you already know the domain and the day, but it holds a limited window and it cannot count.

Step-by-step

1. Resolve the real path and confirm the logging mode. Never assume the file is where the documentation says.

readlink -f /usr/local/apache/logs/modsec_audit.log
ls -lh /usr/local/apache/logs/modsec_audit.log
/var/log/apache2/modsec_audit.log
-rw------- 1 root root 3.1G Aug 15 09:41 /usr/local/apache/logs/modsec_audit.log

Now check how ModSecurity is configured to write it. The file that carries these directives moves between cPanel versions, so search the tree rather than opening a specific file:

grep -rn 'SecAudit' /etc/apache2/conf.d/ 2>/dev/null | grep -v '^Binary'
/etc/apache2/conf.d/modsec2.conf:12:SecAuditEngine RelevantOnly
/etc/apache2/conf.d/modsec2.conf:13:SecAuditLogRelevantStatus "^(?:5|4(?!04))"
/etc/apache2/conf.d/modsec2.conf:14:SecAuditLogType Serial
/etc/apache2/conf.d/modsec2.conf:15:SecAuditLogParts ABIJDEFHZ
/etc/apache2/conf.d/modsec2.conf:16:SecAuditLog logs/modsec_audit.log

SecAuditLogType Serial means everything goes into that one file and the rest of this guide applies as written. If you see Concurrent, there will also be a SecAuditLogStorageDir line, each transaction is its own small file under a dated directory tree, and step 3 becomes a find against that directory. SecAuditLogParts tells you which sections you get. If H is missing, stop and add it — without H there are no rule IDs to read.

2. Find the noisy rules, per domain and per URI. Start with the error log, because it carries the hostname and URI on the same line as the rule ID:

sed -nE 's/.*\[id "([0-9]+)"\].*\[hostname "([^"]+)"\] \[uri "([^"]+)"\].*/\1 \2 \3/p' \
  /etc/apache2/logs/error_log | sort | uniq -c | sort -rn | head -10
   3980 949110 shop.example.com /wp-admin/admin-ajax.php
   3980 942100 shop.example.com /wp-admin/admin-ajax.php
    412 941100 blog.example.net /wp-comments-post.php
    118 913100 shop.example.com /

949110 and 942100 have identical counts on the identical URI, which is the signature of one rule dragging one endpoint over the threshold on its own. 942100 is the candidate. If the counts had not matched, several rules would each be contributing a few points and the fix is different.

3. Pull one whole transaction out of the audit log. Take a unique_id from the error log line you care about, then extract the block it belongs to. Transactions are delimited by --<boundary>-A-- and --<boundary>-Z--, where the boundary is random per transaction, so match on the ID and print the enclosing block:

awk -v id='ZuA9xkPZQ1kAAB8AAAAAAAAA' '
  /^--[^-]+-A--$/ { blk = "" }
  { blk = blk $0 "\n" }
  /^--[^-]+-Z--$/ { if (index(blk, id)) printf "%s", blk }
' /usr/local/apache/logs/modsec_audit.log

On a 3 GB file this takes tens of seconds and prints exactly one block. To re-read the same transaction repeatedly, get the boundary first and use sed:

grep -m1 -B1 'ZuA9xkPZQ1kAAB8AAAAAAAAA' /usr/local/apache/logs/modsec_audit.log
--7a8b9c0d-A--
[15/Aug/2026:09:14:22 --0400] ZuA9xkPZQ1kAAB8AAAAAAAAA 203.0.113.44 54212 192.0.2.10 443
sed -n '/--7a8b9c0d-A--/,/--7a8b9c0d-Z--/p' /usr/local/apache/logs/modsec_audit.log

4. Read the block section by section. Each part answers one question, and you only need three of them for a tuning decision.

The seven parts of a ModSecurity audit-log transaction in order — A, B, C, E, F, H, Z — with what a reader extracts from each, and an arrow from the H section's rule ID to the scoped exclusion that gets written

A gives the timestamp, unique ID, client IP and port. B gives the request headers, where the Host line tells you whose site this was. C is the request body. E is the intermediate response body — what the visitor saw. F is the response headers, where a 403 confirms the block. Z is the terminator. Parts I and J substitute for C when uploads are involved, and part K, if enabled, lists every matched rule in full.

H is the trailer, and it is the one that matters:

--7a8b9c0d-H--
Message: Warning. detected SQLi using libinjection with fingerprint 's&1c' [file "/etc/apache2/conf.d/modsec_vendor_configs/OWASP3/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "45"] [id "942100"] [msg "SQL Injection Attack Detected via libinjection"] [data "Matched Data: s&1c found within ARGS:content: select the plan that fits"] [severity "CRITICAL"] [ver "OWASP_CRS/3.3.4"] [tag "attack-sqli"] [hostname "shop.example.com"] [uri "/wp-admin/admin-ajax.php"] [unique_id "ZuA9xkPZQ1kAAB8AAAAAAAAA"]
Message: Access denied with code 403 (phase 2). Operator GE matched 5 at TX:anomaly_score. [file ".../REQUEST-949-BLOCKING-EVALUATION.conf"] [line "81"] [id "949110"] [msg "Inbound Anomaly Score Exceeded (Total Score: 5)"] [severity "CRITICAL"] [tag "anomaly-evaluation"]
Apache-Handler: proxy:unix:/opt/cpanel/ea-php81/root/usr/var/run/php-fpm/...
Producer: ModSecurity for Apache/2.9.7 (http://www.modsecurity.org/); OWASP_CRS/3.3.4.
Server: Apache
Engine-Mode: "ENABLED"

Four things come out of that. The rule ID is 942100. The message names the check. The matched variable is ARGS:content — a form field, not a URL parameter. And the matched data is select the plan that fits, a customer writing prose that happens to start with a SQL keyword. That is a false positive, and the evidence is in the data field, not in a hunch.

5. Confirm what the rule actually checks before you exclude it. Find the vendor directory, then read the rule:

ls /etc/apache2/conf.d/modsec_vendor_configs/
grep -rn 'id:942100' /etc/apache2/conf.d/modsec_vendor_configs/
OWASP3  cpanel_modsec_vendor_meta
/etc/apache2/conf.d/modsec_vendor_configs/OWASP3/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf:45:    "id:942100,\

If the matched data had been ' OR 1=1-- against an unauthenticated endpoint, this is where you stop and treat it as an attack instead.

6. Write the exclusion, scoped as narrowly as it will go. There are three levels of precision, and you should reach for the first one that solves the problem.

The tightest is removing the rule’s interest in one field, leaving it active everywhere else on the same request:

SecRuleUpdateTargetById 942100 "!ARGS:content"

Next tightest is disabling the rule only on the URI where it misfires. This is the form to use when several fields on one endpoint are affected:

SecRule REQUEST_URI "@beginsWith /wp-admin/admin-ajax.php" \
    "id:1000001,phase:1,pass,nolog,ctl:ruleRemoveById=942100"

If the same endpoint is fine on every other account and only one domain needs the exception, chain a Host check:

SecRule REQUEST_HEADERS:Host "@streq shop.example.com" \
    "id:1000002,phase:1,pass,nolog,chain"
    SecRule REQUEST_URI "@beginsWith /wp-admin/admin-ajax.php" \
        "t:none,ctl:ruleRemoveById=942100"

Custom rule IDs must be unique and outside the vendor ranges; starting at 1000001 and incrementing keeps you clear of them.

7. Put it where cPanel will not overwrite it. In WHM, go to Security Center → ModSecurity Tools → Rules List and use Add Rule, which writes to /etc/apache2/conf.d/modsec2.user.conf. Do not use the Disable toggle on a vendor rule for this — that switches the rule off for every account on the server, which is the outcome this whole page exists to avoid.

To scope by domain at the vhost level instead, use cPanel’s userdata include mechanism, which survives httpd.conf rebuilds:

mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/<user>/<domain>
vi /etc/apache2/conf.d/userdata/ssl/2_4/<user>/<domain>/modsec.conf
/scripts/ensure_vhost_includes --user=<user>

Never edit a file under modsec_vendor_configs/ directly. The next vendor update replaces it and your exclusion disappears with no error anywhere.

Validate it works

Check the syntax before anything else, then reload:

apachectl configtest
Syntax OK
/scripts/restartsrv_httpd
Waiting for "httpd" to restart ..........finished.
httpd (/usr/sbin/httpd) running as root with PID 30412

Now prove the exclusion changed behaviour. Record the audit log’s current size, replay the request that used to be blocked, and read only what was appended:

before=$(stat -c %s /usr/local/apache/logs/modsec_audit.log)
curl -sS -o /dev/null -w '%{http_code}\n' \
  -d 'action=save&content=select the plan that fits' \
  https://shop.example.com/wp-admin/admin-ajax.php
tail -c +$((before + 1)) /usr/local/apache/logs/modsec_audit.log | grep -c 'id "942100"'
200
0

A 200 and a count of 0 together are the success signal: the request went through, and nothing new was written about 942100. A 403 with a count of 1 means the exclusion did not load. A 200 with a count of 1 means something else let the request through and your exclusion is not the reason — keep looking.

Confirm the rule is still armed elsewhere, which is the check people skip:

curl -sS -o /dev/null -w '%{http_code}\n' \
  -d "content=' OR 1=1--" https://shop.example.com/contact/
403

Troubleshooting

The audit log is empty while the error log fills up. SecAuditEngine is RelevantOnly on a stock cPanel install, and SecAuditLogRelevantStatus narrows it further, so requests that matched rules but returned 200 never produce a transaction. SecAuditEngine On captures everything and will fill a disk within hours on a busy server — use it briefly, then put it back.

The unique ID from the error log finds nothing in the audit log. Either the audit log rotated between the two reads, or SecAuditLogType is Concurrent and the transaction is a separate file. In the concurrent case, find it under the storage directory instead: find /var/log/apache2/modsec_audit -name '*ZuA9xkPZ*', substituting your own SecAuditLogStorageDir value.

The exclusion is in the file but the rule still fires. Three usual causes. You excluded 949110 rather than the contributing rule, so the score still climbs and a different blocking path catches it. You put the rule in a vhost include and did not run /scripts/ensure_vhost_includes, so httpd.conf never picked it up. Or your ctl:ruleRemoveById rule is in phase 2 — it must be phase 1 to disarm a phase 2 rule before that rule runs.

A second rule takes over the moment you exclude the first. Common on payload-driven false positives, because the CRS SQL and XSS families overlap heavily. Re-run the ranking in step 2 after each change; if you find yourself excluding a fourth rule on the same endpoint, the endpoint needs a paranoia-level decision, not more exclusions.

Grepping the audit log takes minutes and the server slows down. A multi-gigabyte read competes with live traffic for disk. Copy the file to a scratch volume first, or narrow on a timestamp range before the heavy pattern work. Rotating daily with a short retention keeps this from recurring — but do not truncate during an incident before you have copied the relevant blocks elsewhere.

When this is the wrong approach

If the same rule ID fires across many unrelated accounts, per-domain exclusions are the wrong tool — the vendor rule set does not suit your customer base, and the answer is a vendor or paranoia-level decision. Tracing one rule across multiple customers is its own workflow, covered in correlating audit log entries with customer-side errors.

If the matched data looks like an actual attack, an exclusion is a hole, not a fix. Fix the application or restrict the endpoint.

If every client IP in the log is a Cloudflare address, your rules are matching on the wrong source and IP-based reasoning is meaningless until mod_remoteip is configured correctly.

And if you are reading this log as a security monitor rather than to fix a specific break, it is the wrong data source. The audit log is a debugging artifact — verbose, unindexed, rotated. Alerting and retention belong in a log pipeline, not in grep.

The reference for the directives above is the OWASP Core Rule Set documentation, and WHM’s own interface is documented in the cPanel ModSecurity Tools guide.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.