Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables CRS early blocking #129

Merged
merged 2 commits into from
Jan 11, 2023
Merged

Conversation

M4tteoP
Copy link
Member

@M4tteoP M4tteoP commented Jan 10, 2023

Running the CRS in Anomaly Scoring Mode (default mode), the anomaly score evaluation happens at the end of phase 2 (request body) and phase 4 (response body). Enabling early blocking, the evaluation will happen also at the end of phase 1 (request header) and phase 3 (response headers).
I think that this feature is really handy for proxy-wasm in order to mitigate malicious payloads sent upstream: the earlier we raise an interruption, the better (See also #128).

As a matter of example: CRS rule 913100 is triggered at phase 1 and looks for malicious User-Agents.
Request: curl -I --user-agent "Grabber/0.1 (X11; U; Linux i686; en-US; rv:1.7)" -H "Host: localhost" -H "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" localhost:8080

Before (early blocking disabled):
The request is just blocked at http_response_headers phase, at that time the request already reached upstream.

Coraza: Warning. Inbound Anomaly Score Exceeded (Total Score: 5)
wasm log coraza-filter my_vm_id: 2 interrupted, action "deny", phase "http_response_headers"

After (early blocking disabled):
The request is blocked at http_request_headers phase, right after the detection. It happens before sending anything upstream.

Coraza: Warning. Inbound Anomaly Score Exceeded in phase 1 (Total Score: 5)
wasm log coraza-filter my_vm_id: 2 interrupted, action "deny", phase "http_request_headers"

@jcchavezs
Copy link
Member

jcchavezs commented Jan 11, 2023 via email

@anuraaga
Copy link
Contributor

@jcchavezs The rules in this PR are configuration rules, they don't match and just set configuration globally

@jcchavezs jcchavezs merged commit 5ee6a72 into corazawaf:main Jan 11, 2023
@M4tteoP M4tteoP deleted the enable_early_blocking branch January 12, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants