Skip to main content
MediumSupply chainOWASP A08:2021CWE-353

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

  1. 1Add crossorigin="anonymous" to every cross-origin element that carries an integrity attribute.
  2. 2Confirm the CDN actually returns Access-Control-Allow-Origin; without it the fetch fails whatever the markup says.
  3. 3Use crossorigin="use-credentials" only when the resource genuinely requires cookies, which a public CDN asset does not.

Code examples

Both attributes together

HTML
<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

bash
curl -sI -H 'Origin: https://example.com' \
  https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.min.js \
  | grep -i access-control-allow-origin

References

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.

See every supply chain check

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.

Propose a checkHow a check is built

Scan your own site for cross-origin subresource has integrity but no crossorigin

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Cross-origin subresource has integrity but no crossorigin | VulnRadar