ShipBastion AI Watch — $19/mo

ShipBastion / Security guides / Subresource Integrity (SRI): protect third-party scripts

Guide · VibeShield · Updated 2026-11-30 · 5 min read

Subresource Integrity (SRI): protect third-party scripts

When you load a script from a CDN, whoever controls that CDN controls your page. SRI pins the exact file: if a single byte changes, the browser refuses to run it.

Free scan. Sign in with Google to see the full report; paid plans start with a 7-day free trial.

Generate the hash

curl -s https://cdn.example.com/lib@1.2.3/lib.min.js \
  | openssl dgst -sha384 -binary | openssl base64 -A

Add it to the tag

crossorigin="anonymous" is required for cross-origin files, otherwise the browser cannot check the hash and blocks the file.

<script src="https://cdn.example.com/lib@1.2.3/lib.min.js"
  integrity="sha384-<hash>"
  crossorigin="anonymous"></script>

When SRI does not fit

Files that change on every request (analytics loaders, chat widgets) cannot be pinned. Pin a versioned URL where the vendor offers one, or self-host the file.

Try it on your own domain

Free scan, no card. Pro is $19/mo after a 7-day free trial and covers all four scanners: VibeShield, CiteReady, InboxShield and BrandShield.

FAQ

Do I need SRI for my own scripts?

Not for same-origin files you deploy yourself. SRI matters for files served from someone else's origin.

Related