Silent failure in http_cors.yaml due to unvalidated regex logic
Summary
There is a "silent failure" where the http_cors.yaml module fails to detect vulnerabilities due to an incorrect regex pattern with a trailing space. Currently, the test suite (tests/test_yaml_regexes.py) only checks if a regex is syntactically valid, not if it actually matches the expected data.
As a result, http_cors.yaml passes all tests despite being logically broken for real-world scanning.
Description
In nettacker/modules/vuln/http_cors.yaml, the regex (http|https):\\/\\/evil.com contains a trailing space.
https://github.com/OWASP/Nettacker/blob/2310a8398f788bf7c3b767a153da151ab2a49445/nettacker/modules/vuln/http_cors.yaml#L336-L337
- Expected behavior: Match
https://evil.com - Actual behavior: Fails to match because servers do not append a space to the
Access-Control-Allow-Originheader.
Testing gap: The current tests/test_yaml_regexes.py sees this as a valid regex string and passes it, even though it will never trigger a "Detected" status in a real scan.
Addressed in 90a93457
Hi @Shirshaw64p, thanks for the link! However, I actually have a PR submitted for this already (#1375).
My approach avoids hardcoding specific strings like evil.com and instead enhances the core test_yaml_regexes.py to dynamically validate reflected headers. This fixes the 'silent failure' that allowed the typo to pass originally, which should help prevent similar bugs across all the other modules.
I'd love to get your feedback on the value-matching logic I added to the test suite!
I've investigated this issue and confirmed the bug. The regex (http|https):\/\/evil.com on line 337 of http_cors.yaml has two problems:
- Trailing space: Servers return
Access-Control-Allow-Origin: https://evil.comwithout a trailing space, so the regex will never match. - Unescaped dot: The
.inevil.comshould be\.to avoid matchingevilXcomor similar strings.
I've also identified the testing gap mentioned in the issue: extract_http_regexes() in test_yaml_regexes.py only extracts regexes from content conditions but ignores headers conditions entirely. This allowed the broken regex to pass all tests.
I'll submit a PR with the fix and the test coverage improvement.