<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Peakhour.IO - Caddy</title><link href="https://www.peakhour.io/" rel="alternate"></link><link href="https://www.peakhour.io/feeds/tag/caddy.atom.xml" rel="self"></link><id>https://www.peakhour.io/</id><updated>2026-07-29T09:00:00+10:00</updated><entry><title>How to Tune Coraza on Caddy</title><link href="https://www.peakhour.io/blog/how-to-tune-coraza-waf/" rel="alternate"></link><published>2026-07-29T09:00:00+10:00</published><updated>2026-07-29T09:00:00+10:00</updated><author><name>AC</name></author><id>tag:www.peakhour.io,2026-07-29:/blog/how-to-tune-coraza-waf/</id><summary type="html">&lt;p&gt;Run Coraza and OWASP CRS on Caddy in DetectionOnly, read the audit log and limit each exclusion to the field and route that need it.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Coraza sits inside another server. The connector presents each request to Coraza, Coraza runs the rules and the connector applies the result.&lt;/p&gt;
&lt;p&gt;Handler order decides whether Coraza sees the request in time. Body handling decides which fields the rules can inspect. The logging phase decides what you can investigate later.&lt;/p&gt;
&lt;p&gt;The example deployment runs Coraza as Caddy middleware with OWASP Core Rule Set. The same CRS tuning principles apply to other Coraza connectors. Their installation, request handling and logging need their own tests.&lt;/p&gt;
&lt;h2&gt;Put Coraza in the request path&lt;/h2&gt;
&lt;p&gt;The official Caddy module is compiled into Caddy:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;xcaddy&lt;span class="w"&gt; &lt;/span&gt;build&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;github.com/corazawaf/coraza-caddy/v2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The module documentation requires &lt;code&gt;order coraza_waf first&lt;/code&gt; in the global options block, which places Coraza at the start of Caddy's HTTP handler order.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coraza_waf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;coraza_waf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;load_owasp_crs&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;directives&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;`&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;Include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;coraza&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;recommended&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;SecRuleEngine&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;DetectionOnly&lt;/span&gt;

&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;SecAuditEngine&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RelevantOnly&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;SecAuditLog&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nb"&gt;log&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;coraza&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;audit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;SecAuditLogFormat&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;SecAuditLogType&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Serial&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;SecAuditLogParts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ABFHZ&lt;/span&gt;

&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;Include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;crs&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;Include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;owasp_crs&lt;/span&gt;&lt;span class="o"&gt;/*.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;`&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;reverse_proxy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The Caddy connector's &lt;a href="https://github.com/corazawaf/coraza-caddy#using-owasp-core-ruleset"&gt;&lt;code&gt;load_owasp_crs&lt;/code&gt; option exposes the embedded Coraza CRS files&lt;/a&gt;. The three &lt;code&gt;Include&lt;/code&gt; lines then load the recommended Coraza configuration, the CRS setup and the rules.&lt;/p&gt;
&lt;p&gt;Coraza also supports &lt;a href="https://www.coraza.io/docs/tutorials/coreruleset/"&gt;CRS files installed on disk&lt;/a&gt;. A file-based installation loads the Coraza configuration first, &lt;code&gt;crs-setup.conf&lt;/code&gt; second and the CRS rule files last. Choose one source for CRS and record its version so you can compare rule changes during an upgrade.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.coraza.io/docs/seclang/directives/#secruleengine"&gt;&lt;code&gt;SecRuleEngine DetectionOnly&lt;/code&gt;&lt;/a&gt; runs the rules and suppresses disruptive actions such as &lt;code&gt;deny&lt;/code&gt;, &lt;code&gt;drop&lt;/code&gt; and &lt;code&gt;redirect&lt;/code&gt;. Legitimate requests can complete while you collect matches. Coraza sets &lt;a href="https://www.coraza.io/docs/seclang/directives/#secrequestbodylimitaction"&gt;&lt;code&gt;SecRequestBodyLimitAction&lt;/code&gt; to &lt;code&gt;ProcessPartial&lt;/code&gt;&lt;/a&gt; in this mode. Watch &lt;a href="https://www.coraza.io/docs/seclang/variables/#inbound_data_error"&gt;&lt;code&gt;INBOUND_DATA_ERROR&lt;/code&gt;&lt;/a&gt; because part of an oversized body may remain uninspected.&lt;/p&gt;
&lt;p&gt;Test the Caddy configuration before reloading it. Then send a safe request that triggers a known CRS rule through the public listener. Confirm that the Coraza event appears and the request reaches the upstream in &lt;code&gt;DetectionOnly&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Configure the Coraza audit log&lt;/h2&gt;
&lt;p&gt;The Caddy access log tells you that a request happened. The Coraza audit log tells you which WAF rule matched.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.coraza.io/docs/seclang/directives/#secauditengine"&gt;&lt;code&gt;SecAuditEngine RelevantOnly&lt;/code&gt;&lt;/a&gt; records transactions that produced a warning or error, along with response statuses selected by &lt;code&gt;SecAuditLogRelevantStatus&lt;/code&gt;. CRS rules normally carry the &lt;code&gt;auditlog&lt;/code&gt; action, so their matches can enter the audit log.&lt;/p&gt;
&lt;p&gt;The example uses &lt;a href="https://www.coraza.io/docs/seclang/directives/#secauditlogformat"&gt;Coraza's JSON audit format&lt;/a&gt; and leaves request-body part &lt;code&gt;C&lt;/code&gt; out of &lt;code&gt;SecAuditLogParts&lt;/code&gt;. Request bodies often contain passwords, personal information and customer text. Add body logging only for a controlled investigation, then remove it.&lt;/p&gt;
&lt;p&gt;The serial audit log in the example is convenient during initial tuning. &lt;a href="https://www.coraza.io/docs/seclang/directives/#secauditlogtype"&gt;Coraza warns that serial logging can slow the server&lt;/a&gt; because transactions share one file.&lt;/p&gt;
&lt;p&gt;Concurrent, HTTPS and syslog outputs suit deployments that need another destination. Send the records to a protected log system with rotation, retention limits and restricted access.&lt;/p&gt;
&lt;p&gt;Start each investigation with these fields:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;request time and transaction ID;&lt;/li&gt;
&lt;li&gt;hostname, method and URL;&lt;/li&gt;
&lt;li&gt;rule ID and message;&lt;/li&gt;
&lt;li&gt;CRS tags such as &lt;code&gt;attack-sqli&lt;/code&gt; or &lt;code&gt;attack-xss&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;matched variable name;&lt;/li&gt;
&lt;li&gt;matched data;&lt;/li&gt;
&lt;li&gt;request and response status.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The variable name identifies the input to investigate. &lt;code&gt;ARGS:message&lt;/code&gt; identifies an application field. &lt;code&gt;REQUEST_COOKIES:campaign&lt;/code&gt; identifies a cookie.&lt;/p&gt;
&lt;p&gt;Handle matched data as customer data. Keep enough to reproduce the result, then retain the rule ID, field name and explanation in the permanent exception record.&lt;/p&gt;
&lt;h2&gt;Check what Coraza parsed&lt;/h2&gt;
&lt;p&gt;CRS can inspect only the fields Coraza extracted from the request.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.coraza.io/docs/seclang/directives/#secrequestbodyaccess"&gt;&lt;code&gt;SecRequestBodyAccess On&lt;/code&gt;&lt;/a&gt; enables body buffering and processing. The selected processor determines which collections phase 2 rules can inspect. URL-encoded forms, multipart forms, JSON and XML produce different variables.&lt;/p&gt;
&lt;p&gt;For an unexpected body match, record:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the request &lt;code&gt;Content-Type&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;REQBODY_PROCESSOR&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;REQBODY_ERROR&lt;/code&gt; and &lt;code&gt;REQBODY_ERROR_MSG&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;INBOUND_DATA_ERROR&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;the matched variable name.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://www.coraza.io/docs/reference/body-processing/"&gt;Coraza's current body-processing documentation&lt;/a&gt; shows processor selection by content type. The &lt;a href="https://www.coraza.io/docs/seclang/actions/#ctl"&gt;&lt;code&gt;ctl:requestBodyProcessor&lt;/code&gt; reference&lt;/a&gt; still describes explicit phase 1 selection for JSON and XML. Check &lt;code&gt;REQBODY_PROCESSOR&lt;/code&gt; on the Coraza version and connector you run, then select the processor explicitly when the expected processor is missing.&lt;/p&gt;
&lt;p&gt;A parsing error deserves its own investigation. Coraza documents the risk plainly: the application may accept a body that Coraza's parser rejected. Compare the application's parser with Coraza using the same bytes. Fix a wrong content type or processor selection before writing a rule exclusion.&lt;/p&gt;
&lt;p&gt;Body limits need the same care. &lt;a href="https://www.coraza.io/docs/seclang/directives/#secrequestbodylimitaction"&gt;&lt;code&gt;SecRequestBodyLimitAction ProcessPartial&lt;/code&gt;&lt;/a&gt; inspects the bytes that fit within the limit and sets &lt;a href="https://www.coraza.io/docs/seclang/variables/#inbound_data_error"&gt;&lt;code&gt;INBOUND_DATA_ERROR&lt;/code&gt;&lt;/a&gt;. Raise a limit when the application legitimately accepts larger bodies and the deployment can buffer them safely. Keep an alert for the limit condition so partial inspection remains visible.&lt;/p&gt;
&lt;h2&gt;Load exclusions in the correct order&lt;/h2&gt;
&lt;p&gt;CRS provides two places for local exclusions.&lt;/p&gt;
&lt;p&gt;Use the &lt;a href="/blog/how-to-tune-your-waf/"&gt;general WAF tuning guide&lt;/a&gt; to classify the match and define the exception. Load that exception according to the CRS rule order below.&lt;/p&gt;
&lt;p&gt;A runtime exclusion runs for matching transactions. Load it before CRS so it can change the transaction before the affected rule executes. CRS includes &lt;code&gt;REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example&lt;/code&gt; for this purpose.&lt;/p&gt;
&lt;p&gt;A configure-time exclusion changes a loaded rule. Load it after CRS so the rule already exists. CRS includes &lt;code&gt;RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example&lt;/code&gt; for these changes.&lt;/p&gt;
&lt;p&gt;Keep both files outside the CRS distribution. An upgrade can then replace CRS without replacing your application decisions.&lt;/p&gt;
&lt;p&gt;The order in a Caddy deployment looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;directives&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;`&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;Include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;@coraza&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;recommended&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;SecRuleEngine&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;DetectionOnly&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;Include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;@crs&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;Include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;coraza&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;REQUEST&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;EXCLUSION&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;RULES&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;BEFORE&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;CRS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;Include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;@owasp_crs&lt;/span&gt;&lt;span class="cm"&gt;/*.conf&lt;/span&gt;
&lt;span class="cm"&gt;    Include /etc/coraza/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf&lt;/span&gt;
&lt;span class="cm"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With &lt;code&gt;load_owasp_crs&lt;/code&gt; enabled, the &lt;a href="https://github.com/corazawaf/coraza-caddy/blob/82f09c076b75f0096b8c9ebc58e1ce53e2947198/coraza.go#L106-L108"&gt;Caddy connector merges the embedded CRS filesystem with the operating-system filesystem&lt;/a&gt;. The configuration can include embedded &lt;code&gt;@&lt;/code&gt; files and local &lt;code&gt;/etc/coraza&lt;/code&gt; exclusion files.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://coreruleset.org/docs/2-how-crs-works/2-3-false-positives-and-tuning/"&gt;CRS tuning guide explains the before-and-after placement&lt;/a&gt; and the available exclusion actions.&lt;/p&gt;
&lt;h2&gt;Exclude the field that caused the match&lt;/h2&gt;
&lt;p&gt;Suppose &lt;code&gt;POST /api/jobs&lt;/code&gt; accepts a JSON array. Rule 932125 repeatedly matches legitimate text in each &lt;code&gt;jobDescription&lt;/code&gt; field. In this example, the audit log reports variable names such as &lt;code&gt;ARGS:json.0.jobdescription&lt;/code&gt; and &lt;code&gt;ARGS:json.1.jobdescription&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Coraza accepts a regular expression for the collection key in &lt;code&gt;ctl:ruleRemoveTargetById&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c"&gt;# REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf&lt;/span&gt;
&lt;span class="c"&gt;# Local rule ID 10010 must be unique in this deployment.&lt;/span&gt;
&lt;span class="nb"&gt;SecRule&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;REQUEST_FILENAME&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;@streq /api/jobs&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;\
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;id:10010,phase:1,pass,nolog,t:none,chain&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;SecRule&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;REQUEST_METHOD&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;@streq POST&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;\
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;t:none,ctl:ruleRemoveTargetById=932125;ARGS:/^json\.\d+\.jobdescription$/&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This local rule runs only for &lt;code&gt;POST /api/jobs&lt;/code&gt;. Rule 932125 continues to inspect every other field in those requests and every field on other routes.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;/pattern/&lt;/code&gt; form is a Coraza feature. The &lt;a href="https://www.coraza.io/docs/seclang/actions/#ctl"&gt;Coraza action reference&lt;/a&gt; states that collection-key matching is case-insensitive because Coraza lowercases variable names. Use an exact key such as &lt;code&gt;ARGS:message&lt;/code&gt; when the application has one fixed field. A regular expression earns its place when the application produces a documented family of field names.&lt;/p&gt;
&lt;p&gt;A field can trigger several rules in one attack class. Coraza also supports &lt;code&gt;ctl:ruleRemoveTargetByTag&lt;/code&gt;, for example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;ctl&lt;/span&gt;:ruleRemoveTargetByTag=attack-sqli;ARGS:message
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The exception removes the named field from every rule carrying the literal &lt;code&gt;attack-sqli&lt;/code&gt; tag. Record that scope and confirm that the application protects the field through parameterised queries and suitable validation.&lt;/p&gt;
&lt;p&gt;Configure-time exclusions suit fields with the same meaning everywhere:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c"&gt;# RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf&lt;/span&gt;
&lt;span class="nb"&gt;SecRuleUpdateTargetById&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;942100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;!REQUEST_COOKIES:campaign&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This removes one named cookie from rule 942100 throughout the configuration. A route-specific runtime exclusion is the better starting point for an application field.&lt;/p&gt;
&lt;h2&gt;Check where a chained rule reads the field&lt;/h2&gt;
&lt;p&gt;Some CRS detections are chained rules. The first rule starts the chain and later rules add conditions.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://coreruleset.org/docs/2-how-crs-works/2-3-false-positives-and-tuning/"&gt;CRS tuning documentation&lt;/a&gt; states that target exclusions by ID affect only the first rule in a chain. An exclusion will have no effect when the field is inspected by a later chain member. Removing the complete rule may be the available answer.&lt;/p&gt;
&lt;p&gt;Find the rule in the CRS version you deployed. Check where the target appears in the chain. Then replay the request against that exact version. The rule source and replay result settle the question.&lt;/p&gt;
&lt;h2&gt;Replay the request before and after&lt;/h2&gt;
&lt;p&gt;Save the legitimate request that produced the false positive. Preserve its method, path, query string, content type, important headers and body bytes. Replace credentials and personal data with values that reproduce the same match.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;curl&lt;span class="w"&gt; &lt;/span&gt;--silent&lt;span class="w"&gt; &lt;/span&gt;--show-error&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--dump-header&lt;span class="w"&gt; &lt;/span&gt;before.headers&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--output&lt;span class="w"&gt; &lt;/span&gt;before.body&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--request&lt;span class="w"&gt; &lt;/span&gt;POST&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--header&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Content-Type: application/json&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--data-binary&lt;span class="w"&gt; &lt;/span&gt;@false-positive.json&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;https://api.example.com/api/jobs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Run it once in &lt;code&gt;DetectionOnly&lt;/code&gt; before adding the exclusion. Confirm that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the application returns its normal response;&lt;/li&gt;
&lt;li&gt;the audit log contains the expected rule ID;&lt;/li&gt;
&lt;li&gt;the log names the expected field;&lt;/li&gt;
&lt;li&gt;the request body has no parser or size error.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Add the exclusion, validate the Caddy configuration and reload it. Send the same request bytes again:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;curl&lt;span class="w"&gt; &lt;/span&gt;--silent&lt;span class="w"&gt; &lt;/span&gt;--show-error&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--dump-header&lt;span class="w"&gt; &lt;/span&gt;after.headers&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--output&lt;span class="w"&gt; &lt;/span&gt;after.body&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--request&lt;span class="w"&gt; &lt;/span&gt;POST&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--header&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Content-Type: application/json&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;--data-binary&lt;span class="w"&gt; &lt;/span&gt;@false-positive.json&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;https://api.example.com/api/jobs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The application response should stay the same. The false-positive match should disappear for the excluded field.&lt;/p&gt;
&lt;p&gt;Now send a control request that places a known CRS test value in another field on the same route. Rule 932125 should still inspect that field. Send the original test value to another route as well. The rule should still inspect it there.&lt;/p&gt;
&lt;p&gt;Expect these results:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;the legitimate request works;&lt;/li&gt;
&lt;li&gt;the rule still reads neighbouring fields;&lt;/li&gt;
&lt;li&gt;the rule still runs on other routes.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Keep the request fixtures in a protected test repository. Run them after Coraza, CRS, Caddy or application upgrades.&lt;/p&gt;
&lt;h2&gt;Switch Coraza from DetectionOnly to On&lt;/h2&gt;
&lt;p&gt;Switch &lt;code&gt;SecRuleEngine&lt;/code&gt; to &lt;code&gt;On&lt;/code&gt; in a staging environment after the common legitimate flows run without unexplained matches. Repeat the false-positive replay, the neighbouring-field control and the application's critical user journeys.&lt;/p&gt;
&lt;p&gt;Enable blocking for a limited production audience or hostname when the deployment allows it. Watch WAF responses, upstream errors and business transactions together. A clean audit log has little value when checkout or login has stopped working.&lt;/p&gt;
&lt;p&gt;Document every exception beside the configuration:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;who approved it;&lt;/li&gt;
&lt;li&gt;the affected hostname, method and route;&lt;/li&gt;
&lt;li&gt;the rule ID or tag;&lt;/li&gt;
&lt;li&gt;the excluded field;&lt;/li&gt;
&lt;li&gt;the request that reproduced the match;&lt;/li&gt;
&lt;li&gt;the controls that still inspect or validate the field;&lt;/li&gt;
&lt;li&gt;the date and CRS version tested.&lt;/li&gt;
&lt;/ul&gt;</content><category term="Application Security"></category><category term="Coraza"></category><category term="Caddy"></category><category term="OWASP CRS"></category><category term="WAF"></category><category term="Application Security"></category><category term="False Positives"></category><category term="WAF Tuning"></category></entry></feed>