How to fix: Access-Control-Allow-Origin carries more than one origin
The Access-Control-Allow-Origin header holds two or more origins rather than one. The header is defined to carry exactly one origin, or the single token *.
Why it matters
No browser accepts a multi-valued Access-Control-Allow-Origin, so every cross-origin call to this endpoint fails the CORS check regardless of which origin made it. The usual repair, once someone notices the breakage, is to replace the list with a wildcard or with unconditional reflection of the request's Origin, and both of those are materially worse than the list that was there.
The header is written this way when a server joins its allowlist into one string instead of matching the incoming Origin against the list and echoing only the match. Serving the whole list also discloses which partner origins are trusted. The correct shape is one origin per response, chosen by comparing the request's Origin against the allowlist, with Vary: Origin so caches keep the answers apart.
How to fix it
- 1Match the request's Origin against the allowlist and echo only that single value.
- 2Send no Access-Control-Allow-Origin at all when the Origin is not on the list, rather than sending the list.
- 3Add Vary: Origin so a shared cache cannot serve one origin's response to another.
Code examples
Echo one matched origin
const ALLOWED = new Set([
'https://app.example.com',
'https://admin.example.com',
]);
app.use((req, res, next) => {
const origin = req.headers.origin;
if (origin && ALLOWED.has(origin)) {
res.set('Access-Control-Allow-Origin', origin);
res.set('Access-Control-Allow-Credentials', 'true');
}
res.append('Vary', 'Origin');
next();
});Verify per origin
for o in https://app.example.com https://evil.example; do
echo "$o"
curl -sI -H "Origin: $o" https://api.example.com/v1/items \
| grep -i access-control-allow-origin
doneReferences
Detected automatically by VulnRadar. The check id is api-cors-allow-origin-multiple-values, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
Questions
- How severe is Access-Control-Allow-Origin carries more than one origin?
- VulnRadar rates this low severity in the api 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 api-cors-allow-origin-multiple-values, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Access-Control-Allow-Origin carries more than one origin map to?
- It maps to CWE-346. 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.