Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

Why Does a Correct SRI Hash Still Block a Script?

SRI checks the bytes the browser fetches and prioritizes the strongest algorithm in the integrity attribute. Learn why line endings and stale hashes can block a script.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A correct Subresource Integrity (SRI) hash can still fail if it was calculated from different bytes than the browser fetched, or if the integrity attribute includes a stronger but incorrect hash. SRI verifies the fetched resource’s bytes—not whether the source file looks the same—and when several hash algorithms are listed, the browser checks the strongest one present.

What SRI checks when a script loads

Subresource Integrity lets a browser verify that a fetched resource matches an expected cryptographic digest before using it. The browser calculates a digest from the response bytes, encodes it in Base64, and compares it with the value in the integrity attribute. The comparison is case-sensitive. If the applicable digest does not match, the resource fails integrity verification and the script does not execute. The W3C Subresource Integrity specification describes the mechanism as one that lets user agents verify that a fetched resource arrived without unexpected manipulation.

As an Amazon Associate I earn from qualifying purchases.

Why line endings can make a correct hash fail

A digest covers bytes, not the visual appearance of a file. A line feed (LF) is the byte 0A; a carriage return plus line feed (CRLF) is 0D 0A. Those sequences can look like the same line break in an editor, but they produce different input bytes and therefore different digests.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A hash generated from a checked-out source file proves that the local bytes match that digest. It does not prove that the deployed response is byte-for-byte identical. A checkout setting, build process, deployment pipeline, proxy, or server transformation may change the file. Other differences to check include a final newline, a byte-order mark, minification, bundling, injected banners, content transformations, or an asset version that changed after the hash was generated. These are possible byte-level causes, not evidence that a particular browser normalizes line endings.

Hash the response the browser actually receives

In the browser’s Network panel, identify the final resource URL and inspect the response body, taking redirects and caching into account. Capture those response bytes without passing them through a text editor that might normalize line endings, then calculate the digest using the algorithm in the relevant integrity entry. Compare its Base64 value character-for-character with the attribute.

Why a weaker matching hash may not help

If an integrity attribute contains more than one hash algorithm, the browser selects the strongest algorithm represented in the metadata. The specified order is SHA-256, then SHA-384, then SHA-512, from weaker to stronger. The SRI Level 2 Working Draft dated March 20, 2026 is a draft, not a finalized Recommendation.

For example:

<script src="/app.js"
  integrity="sha384-CORRECT_DIGEST sha512-STALE_OR_INCORRECT_DIGEST"></script>

Here, SHA-512 is the strongest listed algorithm, so a matching SHA-384 entry does not rescue an incorrect SHA-512 entry. If the metadata contains several entries for the strongest algorithm, a match against any one of them can satisfy the check. When adding a stronger algorithm, make sure its digest is current: adding a stale stronger value changes which entries the browser validates.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A troubleshooting sequence for an SRI failure

  1. Check the actual request. In the browser’s Network panel, find the script request, final URL, redirects, cache status, and response body.
  2. Calculate from the response bytes. Capture the served body without text-editor conversion and calculate the digest for the algorithm you are checking.
  3. Compare the full value. Check the Base64 digest character-for-character; SRI matching is case-sensitive.
  4. Inspect every algorithm in the attribute. Identify the strongest listed algorithm and verify the entries at that level. A correct weaker entry cannot compensate for an incorrect stronger one.
  5. Check for a different load failure. Review the console and Network panel for CORS, Content Security Policy (CSP), URL, version, or other errors. These can accompany or be mistaken for an SRI failure, but the error message and request details determine what happened in a particular case.
  6. For a cross-origin script, verify CORS. SRI-protected cross-origin resources require a response that passes CORS. Also serve the page in a secure context; the specification warns that integrity metadata delivered in an insecure context could be altered by a network attacker.

How to distinguish the likely causes

What you observe What to check
The hash matches a local file, but the response digest differs The deployed response has different bytes. Compare line endings and build, deployment, or server transformations.
A weaker entry matches, but a stronger entry is also listed Recalculate the entries for the strongest listed algorithm or remove stale metadata.
The response digest matches, but the request still fails Inspect the console and Network panel for CORS, CSP, an incorrect URL, or another loading problem.
The script is hosted on another origin Confirm that the cross-origin response passes CORS and that the page uses a secure context.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the standard establishes—and what it does not

The specification establishes byte-based verification, strongest-algorithm selection, and the CORS requirement for SRI-protected cross-origin resources. A line-ending mismatch follows from the fact that LF and CRLF are different byte sequences; it is not a claim that browsers silently normalize one into the other. The cause of an individual failure still depends on its response, metadata, and browser diagnostics.

Quick Recap

Best Value
Sale
The Web Application Hacker's Handbook: Finding and Exploiting Security Flaws
  • Comes with secure packaging
  • It can be a gift item
  • Easy to read text

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.