How to fix: Cross-origin subresource has integrity but no crossorigin
A cross-origin script or stylesheet carries an integrity attribute without a crossorigin attribute. Subresource Integrity requires a CORS-enabled fetch, so the browser cannot check the hash.
Why it matters
Without crossorigin the response is opaque to the page, and the specification says a request with integrity metadata whose response is not CORS-enabled fails. In practice the resource either does not load, breaking the page, or in older engines loads unverified. Either way the integrity attribute is providing none of the protection it appears to provide.
This is a two-attribute feature that is very commonly written with one. It is easy to miss because the failure is either a broken page (obvious, but usually blamed on the CDN) or a silently unverified load (invisible). The value crossorigin="anonymous" is right for public CDN assets: it sends no credentials and asks for the CORS headers SRI needs.
How to fix it
- 1Add crossorigin="anonymous" to every cross-origin element that carries an integrity attribute.
- 2Confirm the CDN actually returns Access-Control-Allow-Origin; without it the fetch fails whatever the markup says.
- 3Use crossorigin="use-credentials" only when the resource genuinely requires cookies, which a public CDN asset does not.
Code examples
Both attributes together
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.min.js"
integrity="sha384-REPLACE_WITH_REAL_HASH"
crossorigin="anonymous"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/normalize.css"
integrity="sha384-REPLACE_WITH_REAL_HASH"
crossorigin="anonymous">Confirm the CDN sends CORS headers
curl -sI -H 'Origin: https://example.com' \
https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.min.js \
| grep -i access-control-allow-originReferences
Detected automatically by VulnRadar. The check id is supply-chain-sri-missing-crossorigin, stable across every scan so you can filter or diff on it.
More supply chain checks
- Mediumnpm/yarn Lock File Exposed
- MediumPython Requirements File Exposed
- MediumRuby Gemfile or Gemfile.lock Exposed
- MediumExternal CDN Script Without SRI Hash
- HighHTTP Script Loaded on HTTPS Page
- MediumPHP composer.json or composer.lock Exposed
- HighDockerfile or docker-compose.yml Exposed
- Critical.env File Exposed at Public URL
Questions
- How severe is Cross-origin subresource has integrity but no crossorigin?
- VulnRadar rates this medium severity in the supply chain 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 supply-chain-sri-missing-crossorigin, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Cross-origin subresource has integrity but no crossorigin map to?
- It maps to CWE-353. In the OWASP Top 10 it falls under A08: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.