How to fix: CORS Reflects Origin Without Vary: Origin
Access-Control-Allow-Origin echoes back a specific origin and the response is otherwise cacheable, but there is no Vary: Origin header telling shared caches that the body differs per requesting origin.
Why it matters
A shared or intermediary cache (CDN edge, corporate proxy) that stores this response for one origin can serve the identical cached bytes, including the first origin's Access-Control-Allow-Origin value, back to a request from a different origin. Depending on the cache key, this can break CORS for the second origin or leak the first origin's response body to it.
When Access-Control-Allow-Origin varies per request, RFC 7231 and the Fetch/CORS integration both call for Vary: Origin so caches key their stored copies by the requesting origin. Without it, the response looks like any other cacheable response, and intermediaries are free to reuse it across origins.
How to fix it
- 1Add Vary: Origin to any response whose Access-Control-Allow-Origin value is computed from the request's Origin header.
- 2If the allowlist is small and fixed, consider skipping per-origin reflection and returning a single static Access-Control-Allow-Origin value instead.
Code examples
Express
app.use((req, res, next) => {
const origin = req.headers.origin;
if (ALLOWED.includes(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Vary', 'Origin');
}
next();
});References
Detected automatically by VulnRadar. The check id is cors-reflected-origin-no-vary, stable across every scan so you can filter or diff on it.
More headers checks
Questions
- How severe is CORS Reflects Origin Without Vary: Origin?
- VulnRadar rates this low severity in the headers category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id cors-reflected-origin-no-vary, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does CORS Reflects Origin Without Vary: Origin map to?
- In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.