Ir al contenido

Permissive CORS (ARCH3121)

Esta página aún no está disponible en tu idioma.

Key typescript.security.permissive-cors · Severity warning · Category security · CWE CWE-942

Configuring CORS with a wildcard origin (*), especially together with credentials: true, lets any site call your API with authenticated requests.

import cors from "cors";
app.use(cors({ origin: "*", credentials: true }));
import cors from "cors";
const allowed = ["https://app.example.com"];
app.use(cors({
origin: (o, cb) => cb(null, !o || allowed.includes(o)),
credentials: true,
}));

Use an allowlist of origins; never combine the * wildcard origin with credentials: true.