Skip to content

Kompile Learn

CORS misconfiguration

Only let the websites you trust read your responses, and never combine a reflected origin with credentials.

What it is

CORS headers tell browsers which other websites may read your responses. Echoing back any Origin header effectively trusts every website.

Why it matters

If any site may read your responses with the visitor's cookies, a malicious page can pull private data from your site while the visitor is logged in.

How to fix it

Express (cors)

app.use(cors({ origin: ["https://app.example.com"], credentials: true }));

nginx: fixed allowlist

add_header Access-Control-Allow-Origin "https://app.example.com" always;

Never send Access-Control-Allow-Credentials: true together with an origin copied from the request.

Does your site have this problem?

Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.

Check my site