cors-misconfiguration
Skill2 starsChanged 4 months agoMITView on GitHub
SAST detection methodology for CORS misconfiguration (CWE-942, CWE-346), including reflected Origin with Access-Control-Allow-Credentials:true, null origin acceptance, weak origin regex (unescaped dot, prefix/suffix match, trailing-domain confusion), trusting all subdomains, and wildcard-with- credentials pitfalls. Use when reviewing server code or config that emits Access-Control-Allow-* headers or configures a CORS middleware. Writes confirmed findings to findings/17-cors-misconfiguration.md.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- conjure-3301/skillstheir own version, first seen Aug 17, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- conjure-3301/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository49 other files it gives its agents.
- authentication-flawsSkill
- broken-access-control-idorSkill
- business-logic-flawsSkill
- cicd-and-pipeline-injectionSkill
- code-injectionSkill
- command-injectionSkill
- crlf-and-header-injectionSkill
- cross-site-scriptingSkill
- csrfSkill
- dependency-and-supply-chainSkill
- dom-clobbering-and-postmessageSkill
- graphql-injection-and-abuseSkill
- hardcoded-secretsSkill
- http-request-smugglingSkill
- iac-misconfigurationSkill
- information-disclosureSkill
- insecure-deserializationSkill
- insecure-randomnessSkill
- jwt-vulnerabilitiesSkill
- ldap-injectionSkill
- llm-and-ai-application-securitySkill
- mass-assignmentSkill
- memory-safetySkill
- mobile-android-securitySkill
- mobile-ios-securitySkill
- nosql-injectionSkill
- oauth-oidc-saml-flawsSkill
- open-redirectSkill
- path-traversal-and-file-inclusionSkill
- prototype-pollutionSkill
- race-conditions-and-toctouSkill
- redosSkill
- sast-final-reportSkill
- sast-finding-validationSkill
- sast-methodologySkill
- security-logging-and-monitoring-failuresSkill
- security-misconfiguration-and-headersSkill
- server-side-template-injectionSkill
- session-managementSkill
- smart-contract-securitySkill
- sql-injectionSkill
- ssrfSkill
- unrestricted-file-uploadSkill
- unsafe-parsers-and-yamlSkill
- weak-cryptographySkill
- web-cache-poisoning-and-deceptionSkill
- websocket-securitySkill
- xpath-and-xml-injectionSkill
- xxeSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 89
Do not set Access-Control-Allow-Credentials: true unless strictly required, and never combine credentials with a reflected/wildcard origin.
- Very specific: line 93
Add Vary: Origin when the ACAO value depends on the request origin (cache correctness/safety).
- Very specific: line 95
Keep the allowlist in config, reviewed.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CORS Misconfiguration — SAST Methodology
Class: CORS Misconfiguration · CWE-942 (and CWE-346) · OWASP: A05 Security Misconfiguration
Findings file: findings/17-cors-misconfiguration.md
1. Overview
CORS misconfiguration occurs when a server's Access-Control-Allow-Origin (ACAO)
policy is broader than intended, letting a malicious web origin read authenticated
cross-origin responses. The dangerous combination is a permissive/reflected ACAO
paired with Access-Control-Allow-Credentials: true — the attacker's page then
issues credentialed requests (cookies/HTTP auth) and reads the response, achieving
cross-origin data theft equivalent to a read-side CSRF. The core test: is the ACAO
value derived from (or loosely matched against) the request Origin, and is ACAC
true? If both, any weakness in the origin check is exploitable.
2. Where it lives
- CORS middleware config: Express
cors(), Djangodjango-cors-headers, Flask-CORS, Spring@CrossOrigin/CorsConfiguration, ASP.NETAddCors/WithOrigins, Railsrack-cors, Gors/cors, nginx/Apacheadd_header Access-Control-Allow-Origin. - Hand-rolled header emission: code that reads
req.headers.originand echoes it intoAccess-Control-Allow-Origin. - API gateways / CDN / edge functions setting CORS headers.
- Per-route decorators/annotations overriding a global policy.
3. Sources (tainted input)
The request Origin header is the primary source — attacker-controlled, it
drives reflected/regex-matched ACAO decisions. Secondary: any config value or
allowlist built from user/tenant data, and the Access-Control-Request-* preflight
headers when a handler echoes them (Allow-Headers/Allow-Methods reflection).
4. Sinks (dangerous operations)
// Node/Express — dangerous: reflect Origin + credentials
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', req.headers.origin); // reflected
res.header('Access-Control-Allow-Credentials', 'true'); // → any origin reads response
next();
});
app.use(cors({ origin: true, credentials: true })); // 'true' reflects request origin
app.use(cors({ origin: (o, cb) => cb(null, true) })); // accepts everything# Flask — dangerous
resp.headers['Access-Control-Allow-Origin'] = request.headers.get('Origin')
resp.headers['Access-Control-Allow-Credentials'] = 'true'
CORS(app, supports_credentials=True, origins='*') # * + credentials footgun// Spring — dangerous
@CrossOrigin(origins = "*", allowCredentials = "true") // reflects/allows all + creds
config.addAllowedOriginPattern("*"); // pattern reflects
config.setAllowCredentials(true);// ASP.NET — dangerous
services.AddCors(o => o.AddPolicy("p", b =>
b.AllowAnyOrigin().AllowCredentials())); // invalid combo, or SetIsOriginAllowed(_ => true)// Weak origin validation — dangerous
if (origin.endsWith('.trusted.com')) allow(origin); // evil.com/trusted.com? & sub.trusted.com.evil.com
if (/trusted\.com/.test(origin)) allow(origin); // unanchored, matches trusted.com.evil.com
if (origin.startsWith('https://trusted.com')) allow(origin); // https://trusted.com.evil.com
if (origin === 'null') allow(origin); // sandboxed iframe / data: URI sends null5. Sanitizers / safe patterns
Safe:
- Exact-match the request
Originagainst a hard-coded allowlist of full origins (scheme+host+port), and only then echo that exact value into ACAO; else omit ACAO entirely. - Do not set
Access-Control-Allow-Credentials: trueunless strictly required, and never combine credentials with a reflected/wildcard origin. - For public, non-credentialed APIs, use a static
Access-Control-Allow-Origin: *without credentials (browsers forbid*+credentials anyway). - Add
Vary: Originwhen the ACAO value depends on the request origin (cache correctness/safety). - Keep the allowlist in config, reviewed; reject
nullexplicitly.
Fails / not a real sanitizer:
- Reflecting
Originafter any substring (includes/indexOf), suffix (endsWith('.trusted.com')matchestrusted.com.evil.comand, without the leading dot,eviltrusted.com), or prefix (startsWith('https://trusted.com')matcheshttps://trusted.com.evil.com) test. - Unanchored / unescaped-dot regex (
/trusted\.com/or/^https:\/\/.*trusted/) — matchesattacker-trusted.com,trusted.com.evil.com. - Allowing
null— sandboxed iframes,data:/file:origins, and some redirects sendOrigin: null; an attacker triggers it from a sandboxed iframe. - Trusting all subdomains (
*.trusted.com) when any subdomain has an XSS, subdomain takeover, or user-content host — that subdomain reads the credentialed API. - Believing
*is safe with credentials — code that swaps*→reflected origin to "support credentials" reintroduces reflection. - Setting ACAO correctly but reflecting
Access-Control-Allow-Headers/-Methodsbroadly, or ignoring that simple requests (GET/POSTtext/plain) skip preflight entirely — a restrictive preflight policy doesn't protect them.
6. Detection methodology
- Find CORS header/middleware sinks:
rg -n 'Access-Control-Allow-(Origin|Credentials|Methods|Headers)' rg -n 'cors\(|CORS\(|@CrossOrigin|AddCors|WithOrigins|rack-cors|AllowAnyOrigin|allowCredentials|supports_credentials' - Find Origin reflection:
rg -n 'headers\.origin|getHeader\(\s*["\x27]Origin|request\.headers\.get\(\s*["\x27]Origin|req\.header\(\s*["\x27]Origin' rg -n "origin:\s*true|origin:\s*['\"]?\*|SetIsOriginAllowed" - Determine if credentials are enabled: grep for
Allow-Credentials/credentials: true/supports_credentials/allowCredentials. Reflected/broad ACAO with credentials is the exploitable case. - Audit the origin check where ACAO is derived from
Origin: exact allowlist, or bypassable substring/suffix/prefix/regex? Test againstnull,https://trusted.com.evil.com,https://eviltrusted.com,attacker.trusted.com(if all subdomains trusted). - Check what the endpoint returns: does the credentialed response contain sensitive data (PII, tokens, CSRF tokens, account info)? That's the loot.
- Note simple-request exposure: GET/
text/plainPOST endpoints are reachable without preflight; a permissive ACAO exposes them directly. - Confirm reachability & auth model: is the endpoint session/cookie-authed (so credentialed cross-origin reads matter)?
7. Modern & niche variants
- Reflected Origin +
ACAC: true: the canonical high-impact bug — server echoes whateverOriginit receives and allows credentials, soattacker.comreads any authenticated response. Exploit page:fetch(target, {credentials:'include'}). nullorigin allowed: ACAOnull+ credentials is exploitable from a sandboxed<iframe sandbox>(its origin isnull), adata:URL, or certain redirect chains — a common "we allowed null for local files" mistake.- Weak origin regex/matching: unescaped
.(trusted.commatchestrustedxcom), missing anchors, suffix confusiontrusted.com.evil.com, prefix confusiontrusted.com.evil.comviastartsWith, and no-leading-dot suffixeviltrusted.com. - Trust-all-subdomains + subdomain XSS/takeover:
*.trusted.comallowed; a forgotten/user-content/CI subdomain with XSS or a dangling DNS takeover becomes a trusted origin that reads the main API — CORS turns a low-value subdomain flaw into full data theft (chain withdom-clobbering-and-postmessage/cross-site-scripting). *with credentials pitfalls: browsers rejectACAO: *with credentials, so developers "fix" it by reflecting the origin — reintroducing the reflection bug. AlsoAllow-Credentials: truealongside a wildcard is simply ignored, giving a false sense of restriction.- Preflight bypass via simple requests: GET and
POSTwithContent-Type: text/plain/application/x-www-form-urlencoded/multipart/form-dataare "simple" and skip the OPTIONS preflight; a strictAllow-Methods/Allow-Headerspolicy does nothing for them. Reflected ACAO still exposes their responses. (Also enables JSON-CSRF-style writes — seecsrf.)
8. Common false positives
- Static
Access-Control-Allow-Origin: *on a public, non-credentialed API with no sensitive data andcredentialsdisabled. - Exact-match allowlist echoing only a verified full origin, credentials scoped correctly.
- CORS configured but the endpoint returns no authenticated/sensitive data (nothing to steal cross-origin).
- Reflected origin without
Allow-Credentialson non-sensitive data (lower risk; still note if it exposes anything of value). @CrossOrigin/policy present but overridden by a stricter global filter (verify effective config).
9. Severity & exploitability
Base Medium; High when a reflected/null/bypassable ACAO combines with
Access-Control-Allow-Credentials: true on endpoints returning sensitive
authenticated data (cross-origin account/data theft, CSRF-token exfiltration →
enables CSRF/ATO chains). Low for a permissive policy on non-credentialed,
non-sensitive endpoints. Raise for default-config-vulnerable middleware and
trust-all-subdomains where a subdomain XSS exists. See references/severity-model.md.
10. Remediation
Exact-match the request Origin against a hard-coded allowlist of full origins and
echo only that exact value; otherwise omit ACAO. Enable
Access-Control-Allow-Credentials: true only when required and never with a
reflected or wildcard origin. Reject Origin: null. Avoid *.domain subdomain
wildcards unless every subdomain is fully trusted. Anchor and escape any origin
regex. Add Vary: Origin. Remember simple requests skip preflight — protect
state-changing GET/text/plain endpoints with CSRF defenses regardless of CORS.
11. Output
Append each confirmed finding to findings/17-cors-misconfiguration.md using
references/finding-template.md. Set Class: CORS Misconfiguration, CWE: CWE-942
(or CWE-346 for origin-validation errors), and in Chain potential name the
primitive it provides: cross-origin authenticated read (→ steal PII / session
data / CSRF tokens, feeding csrf and account-takeover chains) and note when it
consumes a subdomain cross-site-scripting/takeover to reach a trust-all-
subdomains allowlist. Record whether credentials are enabled and what sensitive data
the endpoint returns — that determines the chain payoff.
Primitives (controlled): provides DATA_READ (cross-origin); consumes JS_EXEC
References
- CWE-942, CWE-346; OWASP A05:2021; OWASP CORS guidance; PortSwigger CORS misconfiguration research; Fetch Standard CORS protocol.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

