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

fix: deny action with default status 403 #1097

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

M4tteoP
Copy link
Member

@M4tteoP M4tteoP commented Jul 16, 2024

This PR proposes to set 403 as default deny status code instead of delegating it to the connectors.

Why?

If the rule status field is not set, Deny action is currently setting the status code of the interruption equal to 0. Only at the connector level, there is some logic to convert the 0 into a 403. Example in coraza-proxy-wasm:

	statusCode := interruption.Status
	if statusCode == 0 {
		statusCode = defaultInterruptionStatusCode
	}
	if err := proxywasm.SendHttpResponse(uint32(statusCode), nil, nil, noGRPCStream); err != nil {

Delegating it to the connector leads to SecAuditLogRelevantStatus not working properly. The regex ^(?:(5|4)(0|1)[0-9])$ tries to match tx.interruption.Status equal to 0 without succeeding.

This behaviour notably happens with CRS blocking rules that have the deny action not followed by an explicit status.

Possible workaround:

SecAuditLogRelevantStatus "^(?:(5|4)(0|1)[0-9]|0)$"

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.11%. Comparing base (4ff1f76) to head (7fa03db).
Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1097      +/-   ##
==========================================
+ Coverage   82.72%   83.11%   +0.39%     
==========================================
  Files         162      164       +2     
  Lines        9080     7676    -1404     
==========================================
- Hits         7511     6380    -1131     
+ Misses       1319     1041     -278     
- Partials      250      255       +5     
Flag Coverage Δ
default 83.11% <100.00%> (+5.27%) ⬆️
examples 83.11% <100.00%> (+56.68%) ⬆️
ftw 83.11% <100.00%> (+35.74%) ⬆️
ftw-multiphase 83.11% <100.00%> (+33.57%) ⬆️
tinygo 83.11% <100.00%> (+7.71%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@M4tteoP M4tteoP marked this pull request as ready for review July 16, 2024 21:57
@M4tteoP M4tteoP requested a review from a team as a code owner July 16, 2024 21:57
@M4tteoP M4tteoP merged commit 8ebb4a8 into corazawaf:main Jul 18, 2024
9 checks passed
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.

2 participants