waf: one Cookie line, and a 500 ms GeoJS wait (closes #401)
check / check (push) Failing after 14m7s
check / check (push) Failing after 14m7s
A browser sends all its cookies on one Cookie line (RFC 6265), and Go's server joins HTTP/2 Cookie lines into one, so waf now refuses a second line with 431. Further lines only gave a visitor more bytes for the Core Rule Set to read. The refusal logs cookie_lines and cookie_lines_limit. The default of SWW_WAF_ASN_AND_COUNTRY_LOOKUP_TIMEOUT_MS drops from 800 to 500 milliseconds, so the Core Rule Set's share of rproxy's 2 seconds grows from 1 to 1.3 seconds. The slowest worst-case request takes about 0.84 seconds of processor time with every core busy. Model: opus-5-5
This commit is contained in:
1 parent
988f117ef3
commit
01a8a7aa08
9 files changed
+68
-47
No files matched your search
@@ -35,20 +35,20 @@ const (
|
||||
mostJSONRead = 1 << 10
|
||||
)
|
||||
|
||||
// The Core Rule Set has 1 second for one request. That is the default of
|
||||
// The Core Rule Set has 1.3 seconds for one request. That is the default of
|
||||
// rproxy's SWW_RPROXY_WAF_BACKEND_TIMEOUT_MS, 2 seconds, less the default of
|
||||
// SWW_WAF_ASN_AND_COUNTRY_LOOKUP_TIMEOUT_MS, 800 milliseconds, and less 200
|
||||
// SWW_WAF_ASN_AND_COUNTRY_LOOKUP_TIMEOUT_MS, 500 milliseconds, and less 200
|
||||
// milliseconds for waf's other checks.
|
||||
//
|
||||
// A busy host slows all work, so the test does not compare an inspection with
|
||||
// 1 second. It compares it with referenceTime, timed on the same thread just
|
||||
// before and after. inspectionTimeLimitMultiple is how many times
|
||||
// 1.3 seconds. It compares it with referenceTime, timed on the same thread
|
||||
// just before and after. inspectionTimeLimitMultiple is how many times
|
||||
// referenceTime an inspection may take.
|
||||
//
|
||||
// On the host that runs our checks, referenceTime took at least 78
|
||||
// milliseconds, so 13 times it is about 1 second. With that host fully busy,
|
||||
// no try of the slowest request took more than 9.5 times referenceTime.
|
||||
const inspectionTimeLimitMultiple = 13
|
||||
// milliseconds, so 16 times it is about 1.25 seconds. With that host fully
|
||||
// busy, no try of the slowest request took more than 6.7 times referenceTime.
|
||||
const inspectionTimeLimitMultiple = 16
|
||||
|
||||
// referencePattern is what referenceTime matches. Like the Core Rule Set's
|
||||
// rules, it is a regular expression with alternatives and repeats.
|
||||
@@ -221,20 +221,22 @@ const fullLine = lineLimit - 64
|
||||
|
||||
// worstCaseRequests are, for each kind of thing a visitor sends, the requests
|
||||
// that keep the Core Rule Set busiest, within the bounds above. The last
|
||||
// holds the most of everything at once: Cookie lines keep it busier than
|
||||
// other header lines, and the JSON body of the most elements under a key
|
||||
// keeps it busier than the other bodies.
|
||||
// holds the most of everything at once. waf refuses a second Cookie line, so
|
||||
// it has one, and User-Agent and Referer lines, which keep the Core Rule Set
|
||||
// busier than other header lines. The JSON body of the most elements under a
|
||||
// key keeps it busier than the other bodies.
|
||||
func worstCaseRequests() []visitorRequest {
|
||||
fullCookieLine := cookieLine(1)[:fullLine-len("Cookie: ")]
|
||||
|
||||
return append(
|
||||
append(worstCaseHeaders(), worstCaseBodies()...),
|
||||
visitorRequest{
|
||||
name: "the longest request line, three Cookie lines and body",
|
||||
name: "the longest request line, Cookie, User-Agent and " +
|
||||
"Referer lines and body",
|
||||
target: longestTarget()[:fullLine-len("POST HTTP/1.1")],
|
||||
header: http.Header{cookieHeader: {
|
||||
fullCookieLine, fullCookieLine, fullCookieLine,
|
||||
}},
|
||||
header: http.Header{
|
||||
cookieHeader: {cookieLine(1)[:fullLine-len("Cookie: ")]},
|
||||
"User-Agent": {headerValue("User-Agent", fullLine)},
|
||||
"Referer": {headerValue("Referer", fullLine)},
|
||||
},
|
||||
contentType: jsonType, body: jsonOfMostElementsUnderAKey(),
|
||||
},
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user