Skip to main content
MediumClient-sideOWASP A08:2021CWE-353

How to fix: External Script Without Subresource Integrity

One or more external JavaScript files are loaded from CDNs or third-party domains without an integrity attribute. If the CDN is compromised, the script can be replaced with malicious code that runs in all users' browsers.

Why it matters

Supply-chain attacks via compromised CDNs have affected millions of websites. Without SRI, the browser has no way to verify that the script content matches what you tested. A single CDN compromise silently injects malicious code into your site.

Subresource Integrity (SRI) allows browsers to verify that fetched resources haven't been altered. The integrity attribute contains a cryptographic hash of the expected script content: if the served content doesn't match, the browser refuses to execute it.

How to fix it

  1. 1Generate SRI hashes: openssl dgst -sha384 -binary script.js | openssl base64 -A.
  2. 2Add integrity='sha384-...' and crossorigin='anonymous' to external script tags.
  3. 3Use the SRI Hash Generator at https://www.srihash.org/.
  4. 4Pin to a specific version of the CDN resource (not 'latest') so the hash remains valid.

Code examples

Script tag with SRI

HTML
<!-- Bad -->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

<!-- Good -->
<script
  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"
  integrity="sha384-..."
  crossorigin="anonymous"
></script>

References

Detected automatically by VulnRadar. The check id is third-party-script-no-sri, stable across every scan so you can filter or diff on it.

See every client-side check

Questions

How severe is External Script Without Subresource Integrity?
VulnRadar rates this medium severity in the client-side 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 third-party-script-no-sri, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does External Script Without Subresource Integrity 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 external script without subresource integrity

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

External Script Without Subresource Integrity | VulnRadar