discriminator: the header limits are the first check (closes #311)
check / check (push) Waiting to run

A request over 50 cookies or 100 header fields is now refused before any
other check. It causes no lookup, no query to RouteWatch, a DNS blocklist
or AbuseIPDB, no rule file match and no Core Rule Set. The rate limits no
longer count it, and a banned or denied client gets 431 for it. In observe
mode no lookup is made for it. Requests within the limits go through the
same checks in the same order.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-11 00:26:14 +00:00
1 parent ad36dd1775
commit f519e2ca9e
6 files changed
+148 -75

No files matched your search

+19 -15
View File
@@ -147,10 +147,12 @@ request log's `heuristic` field gives that name. `refusal_limit` and
- An IPv6 client is its group: the netblock of `SWW_IPV6_GROUP_PREFIX`
around its address, a /64 by default, since one abuser usually controls a
whole /64. A client is therefore one IPv4 address or one IPv6 group.
3. The tag lists (`tag_lists`; see "Request tags"). Each list that holds the
client adds its tag. Next, `routewatch_tags` adds the client's `asn=` and
`prefix=` tags while `SWW_ROUTEWATCH_URL` is set. A client in
`SWW_ALLOW_NETS` gets no tag.
3. The header limits (`header_limits`; see "Answering in time"). They come
before every other check, since they only count. Next, the tag lists
(`tag_lists`; see "Request tags"). Each list that holds the client adds its
tag. Next, `routewatch_tags` adds the client's `asn=` and `prefix=` tags
while `SWW_ROUTEWATCH_URL` is set. A client in `SWW_ALLOW_NETS` skips the
header limits and gets no tag.
4. The static lists. A client in `SWW_ALLOW_NETS` skips steps 5 to 15, the byte
limits and the error burst. A client in `SWW_DENY_NETS` is refused
(`deny_nets`); a client in both lists is let through.
@@ -183,10 +185,9 @@ request log's `heuristic` field gives that name. `refusal_limit` and
refused and bans the client.
13. The rule files (`rule_files`; see "Rule files"). Matching stops at the first
rule that refuses.
14. The header limits (`header_limits`; see "Answering in time"), and then the
Core Rule Set (`core_rule_set`; see "Attack detection"). A Core Rule Set
match is refused with `403` while `SWW_WAF_MODE` is `block`, and only logged
and alerted while it is `detect`.
14. The Core Rule Set (`core_rule_set`; see "Attack detection"). A match is
refused with `403` while `SWW_WAF_MODE` is `block`, and only logged and
alerted while it is `detect`.
15. The tag refusals again (`tag_deny`), so that `exploitsignature` can refuse
too.
16. A path under `/_sww/` is answered `404`, so that the app never sees that
@@ -2029,7 +2030,6 @@ waits on these, which run in the background:
In `enforce` mode, a question does not wait for GeoJS when it is a request:
- over the header limits;
- from a client on a fetched blocklist, while `SWW_BLOCKLIST_ACTION` is `deny`;
- from a client on the CrowdSec decision list;
- that would take its client over a rate limit at 100% of it, since a percentage
@@ -2041,8 +2041,8 @@ number and country stay unknown until GeoJS has answered. So while
`SWW_UNKNOWN_LIMIT_PERCENT` does not apply to it until then, so not waiting
never lowers its limit.
The static lists and bans come before the lookup, so they never wait. These can
still wait for GeoJS:
The header limits, the static lists and bans come before the lookup, so they
never wait. These can still wait for GeoJS:
- a country list, which needs the answer;
- a rate limit a percentage has lowered, which needs the answer;
@@ -2061,13 +2061,17 @@ over either one:
Real clients never reach these limits. The answer is `deny` with `431`, and the
log line's action is `request_header_too_large`. The refusal makes no ban and is
no offence. The rate limits count the request as usual, so a client that keeps
sending such requests breaks a limit.
no offence.
The header limits are the first check. A request over them is refused before any
other check runs. So it causes no lookup, no query to an outside source and no
rule match, and the rate limits do not count it. A client under a ban or in
`SWW_DENY_NETS` also gets `431` for such a request.
The limits apply on every path and in every `SWW_WAF_MODE`. A client in
`SWW_ALLOW_NETS` skips them, as it skips the Core Rule Set. In `observe` mode
such a request is answered `allow` with `would_action`, and the Core Rule Set
does not read it.
such a request is answered `allow` with `would_action`, and no other check runs
on it.
The Core Rule Set runs each of its rules on each cookie, so thousands of small
cookies would keep it busy for over a second. Within the limits, one long cookie