Permissive CORS

Access-Control-Allow-Origin: *, cors() with no config, origin: true

warningSecuritycors-config

Severity depends on context. Critical when the wildcard comes with credentials.

Why this matters

A wildcard CORS policy lets any website make authenticated requests to your API. This enables CSRF-style attacks where a malicious site can read your users' data.

Example

Flaggedapp/api/data/route.ts
export async function GET(req: Request) {
  return new Response(JSON.stringify(data), {
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  });
}
Fixedapp/api/data/route.ts
const ALLOWED_ORIGINS = [
  "https://myapp.com",
  "https://staging.myapp.com",
];

export async function GET(req: Request) {
  const origin = req.headers.get("origin") ?? "";
  const cors = ALLOWED_ORIGINS.includes(origin)
    ? origin : "";
  return new Response(JSON.stringify(data), {
    headers: {
      "Access-Control-Allow-Origin": cors,
    },
  });
}

How to fix

Replace wildcard '*' with an explicit allowlist of trusted origins. Validate the Origin header against the list on every request.

Reference

In the output
Findings carry "ruleId": "cors-config" in --json and the same id in SARIF and in the terminal.
Silence one line
// prodlint-disable-next-line cors-config
Silence a whole file
// prodlint-disable cors-config at the top of the file
How it works
Matches text patterns. Source on GitHub