Skip to content

ascanrulesBeta: reduce CORS Scan Rule severity for 4xx/5xx responses#6990

Draft
rmtsixq wants to merge 3 commits intozaproxy:mainfrom
rmtsixq:main
Draft

ascanrulesBeta: reduce CORS Scan Rule severity for 4xx/5xx responses#6990
rmtsixq wants to merge 3 commits intozaproxy:mainfrom
rmtsixq:main

Conversation

@rmtsixq
Copy link

@rmtsixq rmtsixq commented Dec 12, 2025

Summary
This PR fixes a false-positive in the CorsScanRule where CORS misconfigurations were being reported as HIGH or MEDIUM severity even when the target server responded with an error status (4xx or 5xx).
Error responses do not expose sensitive content, so the alert severity should not be escalated.

Problem

The original CORS Scan Rule logic evaluated ACAO/ACAC headers without considering the HTTP status code.
As a result, responses like 401 Unauthorized, 404 Not Found, or 415 Unsupported Media Type triggered high-severity alerts even though no sensitive content could be accessed.

This generated misleading scan reports and noise for users.

What This PR Changes

Adds a check for error status codes (>= 400) before evaluating alert severity.

If the response is an error, severity is now set to INFO.

Keeps existing severity logic for 2xx responses (intended behavior).

New Logic:
int statusCode = respHead.getStatusCode();
boolean isErrorResponse = statusCode >= 400;

if (isErrorResponse) {
risk = Alert.RISK_INFO;
} else if (acaoVal.contains("*")) {
risk = Alert.RISK_MEDIUM;
} else if (acaoVal.contains(RANDOM_NAME) || acaoVal.contains("null")
|| (secScheme && acaoVal.contains("http:"))) {
risk = acacVal.isEmpty() ? Alert.RISK_MEDIUM : Alert.RISK_HIGH;
}

Tests Added

Two new parameterized tests were added to ensure correct behavior:

shouldAlertInfoIfErrorStatusCodeEvenWithAcaoAndAcac

shouldAlertInfoIfErrorStatusCodeWithWildcardAcao

These tests verify that 4xx/5xx responses now correctly produce INFO alerts regardless of ACAO or ACAC configuration.

Impact

Prevents misleading HIGH/MEDIUM alerts on authenticated resources or unavailable endpoints.

Reduces false positives for users scanning protected resources.

Improves accuracy and noise reduction during active scans.

Linked Issue

Fixes: #9183

- Check HTTP status code before evaluating risk level
- Error responses (4xx/5xx) now result in INFO level alerts instead of HIGH/MEDIUM
- Added unit tests for error status code handling
- Fixes issue where 401, 404, 415 etc. were incorrectly flagged as high severity
@github-actions
Copy link

github-actions bot commented Dec 12, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@rmtsixq
Copy link
Author

rmtsixq commented Dec 12, 2025

I have read the CLA Document and I hereby sign the CLA

@psiinon
Copy link
Member

psiinon commented Dec 12, 2025

Logo
Checkmarx One – Scan Summary & Details1854d524-f3b6-4068-a6e7-4f100ae146c2

Great job! No new security vulnerabilities introduced in this pull request


Use @Checkmarx to reach out to us for assistance.

Just send a PR comment with @Checkmarx followed by a natural language request.

Examples: @Checkmarx how are you able to help me? @Checkmarx rescan this PR

@thc202 thc202 changed the title Fix: Correct CORS Scan Rule severity for 4xx/5xx responses ascanrulesBeta: Correct CORS Scan Rule severity for 4xx/5xx responses Dec 12, 2025
@thc202 thc202 changed the title ascanrulesBeta: Correct CORS Scan Rule severity for 4xx/5xx responses ascanrulesBeta: reduce CORS Scan Rule severity for 4xx/5xx responses Dec 12, 2025
Copy link
Member

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CHANGELOG.md should also be updated.

@rmtsixq
Copy link
Author

rmtsixq commented Dec 15, 2025

Thanks for the feedback!

I've updated the implementation to lower the alert confidence instead of the risk for error responses, as error pages may still expose sensitive information but exploitability is less certain.

I've also switched to using isClientError/isServerError and updated the CHANGELOG and tests accordingly.

@thc202 thc202 marked this pull request as draft December 22, 2025 17:52
@thc202
Copy link
Member

thc202 commented Dec 22, 2025

Changed to draft since it requires more work as per zaproxy/zaproxy#9183 (comment) (feel free to mark ready once done).

ritorhymes pushed a commit to ritorhymes/cla that referenced this pull request Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

CorsScanRule should not treat 4xx responses as HIGH severity

4 participants