Skip to content

Commit da7df91

Browse files
committed
updates to CRS v4.0.0-rc2, sets equal BodyLimits in default configs
1 parent 5ce7285 commit da7df91

File tree

53 files changed

+3097
-2328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3097
-2328
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ configuration:
106106
"Include @demo-conf",
107107
"SecDebugLogLevel 9",
108108
"SecRuleEngine On",
109-
"Include @crs-setup-demo-conf",
109+
"Include @crs-setup-conf",
110110
"Include @owasp_crs/*.conf"
111111
]
112112
},
@@ -126,7 +126,7 @@ configuration:
126126
"Include @demo-conf",
127127
"SecDebugLogLevel 9",
128128
"SecRuleEngine On",
129-
"Include @crs-setup-demo-conf",
129+
"Include @crs-setup-conf",
130130
"Include @owasp_crs/REQUEST-901-INITIALIZATION.conf"
131131
]
132132
},
@@ -159,7 +159,7 @@ FTW_INCLUDE=920410 go run mage.go ftw
159159
Once the filter is built, via the commands `go run mage.go runEnvoyExample`, `go run mage.go reloadEnvoyExample`, and `go run mage.go teardownEnvoyExample` you can spin up, test, and tear down the test environment.
160160
Envoy with the coraza-wasm filter will be reachable at `localhost:8080`.
161161
The filter is configured with the CRS loaded working in Anomaly Scoring mode.
162-
For details and locally tweaking the configuration refer to [@demo-conf](./wasmplugin/rules/coraza-demo.conf) and [@crs-setup-demo-conf](./wasmplugin/rules/crs-setup-demo.conf).
162+
For details and locally tweaking the configuration refer to [@recommended-conf](./wasmplugin/rules/coraza.conf-recommended.conf) and [@crs-setup-conf](./wasmplugin/rules/crs-setup.conf.example).
163163

164164
In order to monitor envoy logs while performing requests you can run:
165165

example/envoy/envoy-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static_resources:
5656
"directives_map": {
5757
"rs1": [
5858
"Include @demo-conf",
59-
"Include @crs-setup-demo-conf",
59+
"Include @crs-setup-conf",
6060
"SecDefaultAction \"phase:3,log,auditlog,pass\"",
6161
"SecDefaultAction \"phase:4,log,auditlog,pass\"",
6262
"SecDefaultAction \"phase:5,log,auditlog,pass\"",
@@ -66,7 +66,7 @@ static_resources:
6666
],
6767
"rs2": [
6868
"Include @demo-conf",
69-
"Include @crs-setup-demo-conf",
69+
"Include @crs-setup-conf",
7070
"SecDefaultAction \"phase:3,log,auditlog,pass\"",
7171
"SecDefaultAction \"phase:4,log,auditlog,pass\"",
7272
"SecDefaultAction \"phase:5,log,auditlog,pass\"",

example/istio/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ spec:
4545
- Include @demo-conf
4646
- SecDebugLogLevel 9
4747
- SecRuleEngine On
48-
- Include @crs-setup-demo-conf
48+
- Include @crs-setup-conf
4949
- Include @owasp_crs/*.conf
5050
selector:
5151
matchLabels:
@@ -82,7 +82,7 @@ spec:
8282
- Include @demo-conf
8383
- SecDebugLogLevel 9
8484
- SecRuleEngine On
85-
- Include @crs-setup-demo-conf
85+
- Include @crs-setup-conf
8686
- Include @owasp_crs/*.conf
8787
selector:
8888
matchLabels:
@@ -127,4 +127,4 @@ Coraza: Warning. Javascript method detected [file "@owasp_crs/REQUEST-941-APPLIC
127127
[tag "application-multi"] [tag "language-multi"] [tag "attack-xss"] [tag "paranoia-level/1"]
128128
[tag "OWASP_CRS"] [tag "capec/1000/152/242"] [hostname "my-hostname"] [uri "/anything/?arg=<script>alert(0)</script>"]
129129
[unique_id "wTueIQloYpvpWNLzVfy"] thread=27
130-
```
130+
```

ftw/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ RUN apk update && apk add curl
77

88
WORKDIR /workspace
99

10-
# TODO update when new CRS version is tagged: https://github.com/coreruleset/coreruleset/archive/refs/tags/v4.0.0-rc1.tar.gz
11-
ADD https://github.com/coreruleset/coreruleset/tarball/477d8c3431d042294af2651f08d63d10b6f3fd60 /workspace/coreruleset/
12-
RUN cd coreruleset && tar -xf 477d8c3431d042294af2651f08d63d10b6f3fd60 --strip-components 1
10+
# TODO update when new CRS version is tagged: https://github.com/coreruleset/coreruleset/archive/refs/tags/v4.0.0-rc2.tar.gz
11+
ADD https://github.com/coreruleset/coreruleset/tarball/2b92d53ea708babbca8da06cd13decffbc9e31b5 /workspace/coreruleset/
12+
RUN cd coreruleset && tar -xf 2b92d53ea708babbca8da06cd13decffbc9e31b5 --strip-components 1
1313

1414
COPY ftw.yml /workspace/ftw.yml
1515
COPY tests.sh /workspace/tests.sh

ftw/ftw.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ testoverride:
1414
'920100-16': 'Invalid HTTP request line. Rejected by Envoy with Error 400'
1515
'949110-4': 'Related to 920100. Invalid HTTP method. Rejected by Envoy with Error 400'
1616
'941110-4': 'Referer header is sanitized by Envoy and removed from the request'
17-
'941110-9': 'Referer header is sanitized by Envoy and removed from the request'
18-
'920270-5': 'Referer header is sanitized by Envoy and removed from the request'
1917
'941101-1': 'Referer header is sanitized by Envoy and removed from the request'
2018
'920210-2': 'Connection header is stripped out by Envoy'
2119
'920210-3': 'Connection header is stripped out by Envoy'
@@ -26,17 +24,13 @@ testoverride:
2624
'920274-3': 'PL4 - False positive. Envoy Populates :path header, therefore invalid character are detected'
2725
'920274-5': 'PL4 - False positive. Envoy Populates :path header, therefore invalid character are detected'
2826
'932161-7': 'Referer header is sanitized by Envoy and removed from the request'
29-
'932161-8': 'Referer header is sanitized by Envoy and removed from the request'
3027
'932161-9': 'Referer header is sanitized by Envoy and removed from the request'
3128
'932161-10': 'Referer header is sanitized by Envoy and removed from the request'
3229
'932161-11': 'Referer header is sanitized by Envoy and removed from the request'
3330
'932161-12': 'Referer header is sanitized by Envoy and removed from the request'
34-
'932236-6': 'Referer header is sanitized by Envoy and removed from the request'
35-
'932236-7': 'Referer header is sanitized by Envoy and removed from the request'
36-
'932236-28': 'Referer header is sanitized by Envoy and removed from the request'
37-
'932237-6': 'Referer header is sanitized by Envoy and removed from the request'
38-
'932237-7': 'Referer header is sanitized by Envoy and removed from the request'
39-
'932237-8': 'Referer header is sanitized by Envoy and removed from the request'
31+
'932239-6': 'Referer header is sanitized by Envoy and removed from the request'
32+
'932239-7': 'Referer header is sanitized by Envoy and removed from the request'
33+
'932239-19': 'Referer header is sanitized by Envoy and removed from the request'
4034

4135
# Rules working, tests excluded for different expected output
4236
'920270-4': 'Log contains 920270. Test has log_contains disabled.'
@@ -48,7 +42,6 @@ testoverride:
4842
'920280-3': 'Rule 920280 not detected. Host not present. Coraza side'
4943
'920290-1': 'Rule 920290 not detected. Empty Host. Coraza side'
5044
'920430-3': 'Rule 920430 not detected. Proto version. Coraza side'
51-
'920430-5': 'Rule 920430 not detected. Proto version. Coraza side'
5245
'920430-8': 'Rule 920430 not detected. Proto version. Coraza side'
5346
'920430-9': 'Rule 920430 not detected. Proto version. Coraza side'
5447
'934120-23': 'Rule 934120 partially detected. With HTTP/1.1 Envoy return 400. With HTTP/2 Enclosed alphanumerics not detected. Coraza Side'
@@ -57,3 +50,8 @@ testoverride:
5750
'934120-26': 'Rule 934120 partially detected. With HTTP/1.1 Envoy return 400. With HTTP/2 Enclosed alphanumerics not detected. Coraza Side'
5851
'934120-39': 'Rule 934120 partially detected. With HTTP/1.1 Envoy return 400. With HTTP/2 Enclosed alphanumerics not detected. Coraza Side'
5952
'932200-13': 'Unfortunate match inside logs against a different rule log. wip'
53+
54+
# TODO: check why we are failing to deobfuscate these payloads
55+
# tests added via https://github.com/coreruleset/coreruleset/commit/da0314056c4816629bf51ed143dc959a1757db8b
56+
'934131-5': ''
57+
'934131-7': ''

wasmplugin/fs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func init() {
2323
map[string]string{
2424
"@recommended-conf": "coraza.conf-recommended.conf",
2525
"@demo-conf": "coraza-demo.conf",
26-
"@crs-setup-demo-conf": "crs-setup-demo.conf",
26+
"@crs-setup-demo-conf": "crs-setup.conf.example", // Deprecated, points to @crs-setup-conf
2727
"@ftw-conf": "ftw-config.conf",
2828
"@crs-setup-conf": "crs-setup.conf.example",
2929
},

wasmplugin/rules/coraza-demo.conf

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ SecRule REQUEST_HEADERS:Content-Type "^application/json" \
4141
# to the size of data, with files excluded. You want to keep that value as
4242
# low as practical.
4343
#
44+
# Running as a Wasm plugin, we expect Limit equal to MemoryLimit: it would be prevented buffering request body to files anyways.
45+
4446
SecRequestBodyLimit 13107200
4547

46-
SecRequestBodyInMemoryLimit 131072
48+
SecRequestBodyInMemoryLimit 13107200
4749

4850
SecRequestBodyNoFilesLimit 131072
4951

@@ -168,19 +170,11 @@ SecResponseBodyLimitAction ProcessPartial
168170

169171
# -- Filesystem configuration ------------------------------------------------
170172

171-
# The location where Coraza stores temporary files (for example, when
172-
# it needs to handle a file upload that is larger than the configured limit).
173-
#
174-
# This default setting is chosen due to all systems have /tmp available however,
175-
# this is less than ideal. It is recommended that you specify a location that's private.
176-
#
177-
SecTmpDir /tmp/
178-
179173
# The location where Coraza will keep its persistent data. This default setting
180174
# is chosen due to all systems have /tmp available however, it
181175
# too should be updated to a place that other users can't access.
182176
#
183-
SecDataDir /tmp/
177+
# SecDataDir /tmp/
184178

185179

186180
# -- File uploads handling configuration -------------------------------------

wasmplugin/rules/coraza.conf-recommended.conf

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ SecRule REQUEST_HEADERS:Content-Type "^application/json" \
4141
# to the size of data, with files excluded. You want to keep that value as
4242
# low as practical.
4343
#
44+
# Running as a Wasm plugin, we expect Limit equal to MemoryLimit: it would be prevented buffering request body to files anyways.
45+
4446
SecRequestBodyLimit 13107200
4547

46-
SecRequestBodyInMemoryLimit 131072
48+
SecRequestBodyInMemoryLimit 13107200
4749

4850
SecRequestBodyNoFilesLimit 131072
4951

@@ -168,19 +170,11 @@ SecResponseBodyLimitAction ProcessPartial
168170

169171
# -- Filesystem configuration ------------------------------------------------
170172

171-
# The location where Coraza stores temporary files (for example, when
172-
# it needs to handle a file upload that is larger than the configured limit).
173-
#
174-
# This default setting is chosen due to all systems have /tmp available however,
175-
# this is less than ideal. It is recommended that you specify a location that's private.
176-
#
177-
SecTmpDir /tmp/
178-
179-
# The location where Coraza will keep its persistent data. This default setting
173+
# The location where Coraza will keep its persistent data. This default setting
180174
# is chosen due to all systems have /tmp available however, it
181175
# too should be updated to a place that other users can't access.
182176
#
183-
SecDataDir /tmp/
177+
# SecDataDir /tmp/
184178

185179

186180
# -- File uploads handling configuration -------------------------------------

0 commit comments

Comments
 (0)