fix(WILDCARD_CORS): detect null-origin bypass and wildcard-subdomain origins#46
Open
dmchaledev wants to merge 1 commit into
Open
fix(WILDCARD_CORS): detect null-origin bypass and wildcard-subdomain origins#46dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
…origins
The CORS rule only matched a literal "*" entry, silently passing two
other classic permissive-origin misconfigurations:
- the "null" origin, which is reachable from sandboxed iframes,
data:/file: documents, and some redirects — a well-known way to
defeat an allow-list; and
- wildcard-subdomain patterns such as "https://*.example.com", which
trust every current and future subdomain, including any that later
becomes attacker-controlled.
Both are now flagged under the existing MEDIUM WILDCARD_CORS rule.
Evidence lists only the offending origins (case-insensitive "null"
match), so specific, safe origins in the same allow-list are not
reported. Adds regression tests for the null-origin and
wildcard-subdomain cases and broadens the negative test to a
multi-origin safe allow-list.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0141pv1QamJWRKky2mJxVpi1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
WILDCARD_CORSrule (src/rules/config-rules.ts) only matched a literal"*"entry (origins.includes('*')). It silently passed two other classic permissive-origin misconfigurations that defeat the same-origin policy just as effectively:"null"origin — reachable from sandboxed iframes,data:/file:documents, and some cross-origin redirects. Allow-listingnullis a well-documented way to bypass a CORS allow-list (PortSwigger: CORS vulnerabilities).https://*.example.com— these trust every current and future subdomain, including any that later becomes attacker-controlled (dangling DNS, takeover, a compromised low-value subdomain).Both are now flagged under the existing MEDIUM
WILDCARD_CORSrule. This is a false-negative fix in the scanner's core mission (an advertised "unsafe defaults / CORS wildcards" check), consistent with recently-accepted rule-hardening PRs that catch obvious cases an existing rule missed.Before / after
// cors.origins: ["https://app.example.com", "null", "https://*.internal.example.com"]"*""null""https://*.example.com""https://app.example.com"Behavior details
nullorigin (matchesOrigin: nullas a browser sends it).evidencelists only the offending origins, so specific/safe origins in the same allow-list are not reported as evidence.*appearing anywhere other than a bare"*"is treated as a wildcard host pattern.ruleId, severity (MEDIUM), anddocsUrlas before — the rule title is generalized from "Wildcard CORS Origin Configured" to "Insecure CORS Origin Configured" to cover all three cases. No newRuleIdand no scoring change.Tests
"null"origin (case-insensitive) fires and reports only the offending origin.120 passed.tsc --noEmit,eslint --max-warnings 0, andnpm run buildall pass; CLI smoke-tested end-to-end against a config exercising all three cases.Acceptance criteria
cors.originscontaining"null"produces aWILDCARD_CORSfinding.https://*.example.com) produces a finding."*"still fires (no regression).🤖 Generated with Claude Code
https://claude.ai/code/session_0141pv1QamJWRKky2mJxVpi1
Generated by Claude Code