How to fix: CORS preflight cache time is too long
The Access-Control-Max-Age value is very large, caching CORS preflight results for an excessively long time.
Why it matters
A very long preflight cache means browsers will not re-check CORS permissions if you change your policy, potentially allowing stale permissions to persist for days or weeks on the client.
Set Access-Control-Max-Age to a reasonable value (600 seconds recommended) to balance performance and policy update latency.
How to fix it
- 1Set Access-Control-Max-Age to 600 seconds (10 minutes) or less
- 2Browsers impose their own cap (Chrome: 7200s, Firefox: 86400s)
Code examples
Reasonable preflight cache
return new Response(null, {
headers: {
"Access-Control-Max-Age": "600", // 10 minutes
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
},
});References
Detected automatically by VulnRadar. The check id is access-control-max-age-long, stable across every scan so you can filter or diff on it.
More headers checks
Questions
- How severe is CORS preflight cache time is too long?
- 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 access-control-max-age-long, 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.