
Element Code: SE-015
<link> tag that has no integrity attribute. Without Subresource Integrity, the browser will apply whatever bytes that host returns, even if the file was swapped or tampered with. Add an SRI hash plus crossorigin so the browser refuses to load altered CSS.What Subresource Integrity is and what the flag means
Subresource Integrity, SRI, is a browser feature defined by the W3C. You put a cryptographic hash of the exact file you expect into the integrity attribute of a <script> or <link> tag. When the browser downloads the resource, it hashes what it received and compares. Match, it applies the file. Mismatch, it blocks the file entirely and logs a console error. Simple, and effective.
This check fires when a stylesheet is pulled from an external origin (a public CDN, a font or widget host, a third party design kit) using a bare <link rel="stylesheet" href="..."> with no integrity attribute. That means your page will trust and render whatever CSS that host serves at request time, with no verification that it is the file you intended.
Why unverified third party CSS is a real risk
People wave this away with "it is only CSS, what is the worst that happens." More than you would like. CSS is not passive decoration. It can:
- Exfiltrate data. CSS attribute selectors combined with background image requests can leak the contents of form fields and hidden tokens to an attacker controlled server. This is a documented class of attack, not theory.
- Deface and phish. Malicious CSS can hide the real UI, overlay a fake login prompt, reposition buttons over links, or swap your branding, all without touching a line of your HTML.
- Break the page. Even a botched or corrupted file from the CDN wrecks your layout for every visitor until someone notices.
The threat model that matters is supply chain: you do not control the CDN. If that host is compromised, its account is hijacked, or a rogue update ships, your visitors silently receive weaponized bytes served from your own page. This is exactly the pattern behind real world CDN and third party script incidents. SRI is the seatbelt. It does not stop the crash on the CDN, it stops the crash from reaching your users, because the hash will not match and the browser refuses the file.
How SRI verification flows
The fix, concretely
A protected stylesheet link looks like this. Two attributes get added: integrity with the algorithm prefixed base64 hash, and crossorigin="anonymous", which SRI requires for cross origin resources so the response is fetched in a way the browser can validate.
<link rel="stylesheet"
href="https://cdn.example.com/lib/3.4.1/lib.min.css"
integrity="sha384-9ndCyUa...base64hash...=="
crossorigin="anonymous">Step by step:
- Pin a version. SRI only works against an immutable file. Reference a specific version URL, never a "latest" or floating path, because the hash of latest changes without warning and blocks your own site.
- Generate the hash. Use the SRI Hash Generator at srihash.org, or on the command line:
openssl dgst -sha384 -binary file.css | openssl base64 -A, then prefix withsha384-. Prefer sha384 or sha512 over sha256. - Add both attributes. Put the
integrityandcrossorigin="anonymous"attributes on the link tag. - Test in a browser. Load the page, open DevTools, and confirm the stylesheet applies and there is no integrity error in the console. Then flip one character of the hash and confirm the browser blocks it, so you know the guard is live.
- Repeat for every external stylesheet the check flagged, and script it into your build so new dependencies get hashed automatically.
SRI at a glance
| Attribute or choice | Value | Note |
|---|---|---|
integrity | sha384-... | Algorithm prefix plus base64 hash |
crossorigin | anonymous | Required for cross origin SRI |
| Algorithm | sha384 or sha512 | sha256 allowed but weaker |
| Version | Pinned, immutable | Never "latest" |
| Self hosted CSS | SRI optional | Same origin, lower risk |
How to detect it
- Screaming Frog: crawl and check the resource and security reports, or use custom extraction to flag external
<link rel="stylesheet">tags that lack anintegrityattribute. - Browser DevTools: the Network tab shows every external CSS request and its origin, and the Security or Issues panel surfaces missing integrity warnings.
- Security scanners: tools like Mozilla Observatory and various header and dependency scanners report missing SRI on subresources.
- Manual source check: grep the rendered HTML for external stylesheet links and confirm each cross origin one carries integrity plus crossorigin.
Do this / skip that
- Add integrity plus crossorigin to every external stylesheet
- Pin an exact, immutable version URL
- Use sha384 or sha512 for the hash
- Automate hash generation in your build pipeline
- Test that a wrong hash actually blocks the file
- Hash a "latest" or floating URL that can change under you
- Dismiss CSS as harmless, it can leak and phish
- Forget crossorigin, SRI silently will not validate without it
- Leave a stale hash after you upgrade the library version
- Assume the CDN will never be compromised
What good looks like
Every stylesheet you pull from an origin you do not control carries a pinned version, an sha384 or sha512 integrity hash, and crossorigin="anonymous". Your build regenerates those hashes on every dependency bump so they never go stale. If a CDN ever serves altered CSS, your visitors get a blocked resource and a console error instead of a hijacked page. That is the trade you want: fail closed, not silently compromised.
FAQ
Does SRI affect SEO or page speed?
Do I need SRI on my own self hosted CSS?
What happens if the hash does not match?
Why is crossorigin required?
crossorigin="anonymous", SRI cannot verify and the resource fails.We audit your subresources, add SRI where it counts, and lock down the supply chain so a compromised CDN cannot reach your users.
Claude Vincent is a technical SEO consultant focused on crawlability, rendering, and AI-search visibility. He writes the field guides and case studies at SEO ProCheck, with a bias toward the durable, unglamorous work that decides whether search engines and AI answer engines can actually read and cite a site.
About SEO ProCheck
Technical SEO consulting and GEO strategy with 20 years of enterprise experience. Case studies, resources, and tools for search and AI visibility.
Work With Me
Technical SEO audits, GEO strategy, site migrations, and international SEO. Hourly consulting for teams who need hands-on support, not just reports.







