waf decides in parallel: the GeoJS wait and the local checks overlap, the first answer wins, and the local checks get 500 ms
#405
Notifications
Due Date
No due date set.
Blocks
Depends on
Reference: sneak/smallwebwaf#405
Reference in new issue
Block a user
Split from #401. Second of three.
Start only once #404 (the GeoJS lookup as a package of its own) is merged into
next. This issue uses that package's separate caller wait.What sneak asked for
Reworded from his comments:
waf(#403 (comment)).rproxywaits. A visitor able to deny service is a bug inwaf(#385 (comment)).Where the code is today
checkClientininternal/waf/request.godoes everything one after another:beforeLookup;afterLookup, which end with the Core Rule Set. It takes up to about a second on the slowest request a visitor can send.So the two waits add up. They are the only two things in a decision that take time. Every other check reads the request or
waf's memory and takes microseconds.One fact shapes the design. Coraza cannot stop an inspection part-way. The pinned version carries a context on each transaction, but its rule evaluation never looks at it. So "stopping" the Core Rule Set can only mean that
wafstops waiting and drops the result. The inspection ends by itself, bounded by the fixed size limits in "Answering in time" ofSPEC.md.To build
beforeLookupstay first, one after another, in today's order: header limits, tag lists, routewatch tags,SWW_WAF_DENY_NETS, bans. A request they refuse starts no lookup wait and no inspection, as now. Otherwise a banned client could keep a processor busy with inspections nobody waits for.wafanswers at once and does not wait for the other. The lookup itself goes on and its answer is kept.wafrefuses the request:denywith status503;heuristicnames the check that had not finished;SWW_WAF_CORE_RULE_SET_MODEsays;observemode it is logged aswould_actionand the request is allowed, like every refusal.Keep as it is:
SWW_WAF_ALLOW_NETSis approved before every check, and nothing else starts. That is the only outright approvalwafhas. No setting exempts a country or an AS number fromwaf, and this issue adds none.observemode the first refusal still ends the checks and is logged as what would have happened.Do not patch Coraza, and build nothing to stop an inspection.
The timing test
TestTheCoreRuleSetInspectsEachWorstCaseRequestInTimeininternal/coreruleset/inspectiontime_test.gochecks that the slowest request a visitor can send is inspected within about 1 second of processor time.internal/corerulesettakes to inspect, at paranoia level 4 with the most of a body read. Give it with no other load and with every core busy. Commit no new timing test for it.Done when
Each point has a test. Hold the lookup and the local checks with stand-ins, under
testing/synctestwhere time matters, so no test compares real work with the clock.wafanswers after the longer of the two limits, not after their sum.beforeLookupstarts no lookup wait and no inspection. The tests of this ininternal/waf/answertime_test.gostill hold.503, the log line has the new action, and there is no ban and no offence. Inobservemode the request is allowed withwould_action.SWW_WAF_ALLOW_NETSis allowed at once and nothing else starts.internal/waf, which the race detector checks.SPEC.md: "What happens to a request", "The answer" and "Answering in time";docs/request-log.md: the new action;README.mdanddocs/settings.md, wherever they give the order of the checks or these times.make checkpasses.Readings taken
Each is mine, not sneak's ruling, and each is cheap to reverse.
waf's host is so busy that an ordinary request takes over 500 ms, that request is refused too. Today it would getSWW_RPROXY_WAF_BACKEND_NO_ANSWER_DISPOSITIONafter 2 seconds.503, no ban, no offence.rproxyalready answers503whenwafgives no answer in time and the setting isdeny. A ban would turn an overloaded host into bans of ordinary visitors. Reversing it is one constant and two lines.detectmode, where a match refuses nothing. The limit is on the local checks as a whole, not a finding of the Core Rule Set.Not checked
Model: fable-5-2
Not started: this issue waits on the GeoJS lookup package (#404), which is still open with no PR merged into
next.Model: opus-5-5