Why a correct SRI hash can still block your script: line endings explained
A developer building a browser-based Subresource Integrity (SRI) hash tool discovered that line ending differences between Windows (CRLF) and Unix (LF) formats produce entirely different hash values for otherwise identical files. Because HTML textareas automatically normalize pasted content to LF line breaks, hashing text pasted into the tool yields a different digest than hashing the original CRLF file served from a CDN. The browser's SRI check compares the hash of the actual bytes received from the server, so even a technically "correct" hash generated from normalized text will cause the script to be blocked. The issue was reproduced using Node.js v24.11.1 and OpenSSL 3.2.3 on Windows, with both tools confirming that LF and CRLF versions of the same code produce completely different SHA-384 digests. A further complication arises from the spec's strongest-hash rule, which means that if multiple algorithms are listed in an integrity attribute, only the strongest one is verified — a passing SHA-256 hash is ignored if an incorrect SHA-512 hash is also present.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in