Skip to content
File

Blob: waf/engine_profile.go

go59 lines
1package waf
2 
3// The engine configuration stays coupled to Coraza. These overrides adapt its
4// recommended configuration to a general HTTP tunnel, rather than imposing a
5// web application's methods, media types, or upload-size policy.
6const engineProfile = `
7SecAuditEngine Off
8SecResponseBodyAccess Off
9SecUploadKeepFiles Off
10SecRequestBodyLimitAction ProcessPartial
11
12# A prefix of a valid JSON document is usually not itself valid JSON. Keep the
13# parser-error guard except for this specific JSON truncation error. Resource
14# limits, multipart parser errors, and other parsing failures still reject.
15SecRuleRemoveById 200002
16SecRule INBOUND_DATA_ERROR "@eq 1" "id:10001,phase:2,t:none,pass,nolog,chain"
17 SecRule REQBODY_PROCESSOR "@streq JSON" "t:none,chain"
18 SecRule REQBODY_PROCESSOR_ERROR_MSG "@streq invalid JSON" "t:none,ctl:ruleRemoveById=200002"
19SecRule REQBODY_ERROR "!@eq 0" "id:200002,phase:2,t:none,deny,status:400,nolog"
20`
21 
22// CRS's default method/content-type allowlists describe a conventional website.
23// Specter also carries WebDAV, APIs, and binary/streaming protocols. Their URL
24// and header checks remain enabled, with body inspection limited to formats
25// handled by the request adapter.
26const tunnelProfile = `
27SecRuleRemoveById 911100 920420
28`
29 
30func ruleCategory(tags []string) string {
31 for _, tag := range tags {
32 switch tag {
33 case "attack-sqli":
34 return "SQL injection"
35 case "attack-xss":
36 return "Cross-site scripting"
37 case "attack-rce":
38 return "Command injection"
39 case "attack-lfi":
40 return "Local file access"
41 case "attack-rfi":
42 return "Remote file access"
43 case "attack-ssrf":
44 return "Server-side request forgery"
45 case "attack-protocol":
46 return "HTTP request format"
47 case "attack-injection-php":
48 return "PHP injection"
49 case "attack-injection-java":
50 return "Java injection"
51 case "attack-session-fixation":
52 return "Session fixation"
53 case "attack-reputation-scanner":
54 return "Known scanner"
55 }
56 }
57 return "Web attack pattern"
58}