CORS is configured to echo the request's Origin back as Access-Control-Allow-Origin.
Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.
Why this matters
Reflecting the incoming origin is functionally identical to allowing EVERY origin: any site can make cross-origin requests and read the responses. Combined with credentials this becomes a CSRF / account-takeover primitive, because the browser will attach the victim's cookies to the attacker-controlled request.
This is distinct from a literal * wildcard. Here the origin is reflected dynamically, which silently defeats the same-origin policy while looking "scoped" in code review.
Use an explicit allowlist of trusted origins instead:
cors({ origin: 'https://app.example.com', credentials: true })cors({ origin: ['https://app.example.com', 'https://admin.example.com'] })- a callback that validates against an allowlist before calling
cb(null, true).
Never set Access-Control-Allow-Origin to req.headers.origin, never use origin: true, and never write a callback that unconditionally returns cb(null, true).
Suppressing this rule
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.
// oauthlint-disable-next-line auth.cors.reflect-origin -- <reason>