Nettacker icon indicating copy to clipboard operation
Nettacker copied to clipboard

Silent failure in http_cors.yaml due to unvalidated regex logic

Open jess-tech-lab opened this issue 8 months ago • 3 comments

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-Origin header.

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.

jess-tech-lab avatar Mar 08 '26 21:03 jess-tech-lab

Addressed in 90a93457

Shirshaw64p avatar Mar 08 '26 23:03 Shirshaw64p

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!

jess-tech-lab avatar Mar 08 '26 23:03 jess-tech-lab

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:

  1. Trailing space: Servers return Access-Control-Allow-Origin: https://evil.com without a trailing space, so the regex will never match.
  2. Unescaped dot: The . in evil.com should be \. to avoid matching evilXcom or 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.

xovishnukosuri avatar Mar 14 '26 05:03 xovishnukosuri