How to fix: CORS Endpoint Missing Vary: Origin
An endpoint returns a dynamic Access-Control-Allow-Origin header (reflecting the request's Origin) without including Vary: Origin. Caches that store this response may serve one origin's response to a different origin.
Why it matters
A shared cache that stores the response for origin A (with Access-Control-Allow-Origin: https://a.example.com) without a Vary: Origin instruction may then serve that cached response to origin B. Origin B's browser reads the ACAO header and may erroneously believe it has cross-origin access.
When a server reflects the request's Origin value in Access-Control-Allow-Origin, caches need Vary: Origin to know they must store separate copies per Origin. Without it, one origin's allowed-response may be returned to a different origin, bypassing the CORS allowlist.
How to fix it
- 1Add Vary: Origin to every response that dynamically sets Access-Control-Allow-Origin based on the request's Origin.
- 2Alternatively, use a fixed ACAO value (not reflected) or set Access-Control-Allow-Origin: * for fully public endpoints.
Code examples
Node.js (express/cors)
import cors from 'cors';
app.use(cors({
origin: ['https://app.example.com', 'https://admin.example.com'],
credentials: true,
}));
// express-cors automatically adds Vary: Origin when using an allowlistNginx manual CORS
if ($http_origin ~* 'https://(app|admin)\.example\.com') {
add_header Access-Control-Allow-Origin $http_origin;
add_header Vary Origin; # Required
}References
Detected automatically by VulnRadar. The check id is vary-origin-missing-cors, stable across every scan so you can filter or diff on it.
More config checks
- MediumNo Rate-Limit Policy Detected
- MediumVary: Cookie Missing on Cookie-Bearing Response
- LowSet-Cookie Header Exceeds 4 KB
- LowVary Header Missing on Compressed Responses
- InfoDownloadable Content Served as inline
- InfoX-XSS-Protection Header Is Deprecated
- LowServer-Timing Exposes Cache Timings
- LowVary: Cookie on Static Resource
Questions
- How severe is CORS Endpoint Missing Vary: Origin?
- VulnRadar rates this medium severity in the config 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 vary-origin-missing-cors, which stays the same between runs so you can filter, diff, or gate CI on it.
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.