Skip to main content

Web application firewall

The WAF is configured per proxy host under Host → Edit → Security · WAF. It is built on Coraza 2.6.2 with OWASP CRS 4.25.0, pinned into the image.

Modes​

ModeEffectWhen to use it
Off (explicit)No inspection handler is compiled for the host.Every host until you have reviewed its traffic.
MonitorRequests are inspected; matches are recorded as WAF_MATCH events with the rule id; the request is forwarded.The first one to two weeks for a new host.
BlockThe rule set is enforced. A match returns the host's error page with 403 and a reference.After the monitor events look like false positives only.
Inherit the deployment defaultFollows the node default shown in the selector.When one policy should apply to most hosts.

Mode is a property of the host, so a single deployment can run one host in monitor mode and another in block mode.

What is inspected​

  • Requests only. Response bodies are not buffered or inspected in this release, which is why logins, streaming and downloads keep working.
  • The request body is inspected up to 32 MiB. A larger body is inspected partially and forwarded; it is never rejected merely for its size.
  • Inspection happens before the request reaches the upstream.
  • A matching request in monitor mode still reaches the origin. In block mode the origin never sees it.

Choosing block mode​

  1. Enable Monitor and apply a revision.
  2. Let real traffic through for a period.
  3. Open Security → WAF and review the matched rule ids, hosts and paths.
  4. If the matches are attacks, switch the host to Block. If a match is a false positive, add a narrow exception first.

In block mode a matching request never reaches the origin. The visitor sees the host's error page with a reference you can look up in Security → Security events:

The block page a visitor sees, with the request reference that identifies the event

Narrow exceptions​

An exception turns off one rule for an optional method, an optional path prefix and an optional single field:

Field selectorTargets
ARGS:nameOne query or form argument
REQUEST_HEADERS:nameOne request header
REQUEST_COOKIES:nameOne cookie
REQUEST_URIThe URI itself
REQUEST_BODYThe body
  • A reason is mandatory; the expiry date is optional.
  • An expired exception stays in the record but is not compiled.
  • An exception for GET /search ARGS:q admits that one request shape only; the same rule still blocks on every other path.
  • Free-form directives cannot be written through the console. Unsafe field values are rejected, not escaped.

The node's detailed WAF record​

Every match is also written to a raw record on the node for debugging:

PropertyDefault
File/data/caddy/waf-audit.log
AccessOwner-only (0600); the directory is not published
RotationBy size (32 MiB) and by age (24 hours)
RetentionRolled files past the retention age are deleted, and the retained set is capped at 512 MiB
ContentRule id, message, host, URI and the per-request reference — never a body, cookie or credential

The raw record stays on the node. It is not stored in PostgreSQL and is not part of the central aggregates; only the sanitized security-event summary is stored centrally. Exclude the raw record from backups and replication, or accept that it will be captured.

Checking the engine​

The versions above can be confirmed from the engine container:

docker compose exec -T caddy caddy version
docker compose exec -T caddy caddy list-modules --versions | grep -E 'waf|crowdsec'

A mismatch between the environment's recorded CRS version and the rule bundle would be a build defect. The bundle is what the image contains.