security: add SRI hash to CDN-loaded Redoc script#19
Open
dmchaledev wants to merge 1 commit into
Open
Conversation
Without an integrity attribute, a CDN compromise could silently serve tampered JavaScript to every visitor of the API docs site. The sha384 hash was computed directly from the published redoc@2.5.3 bundle and locks the browser to that exact byte sequence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XXMsynQpRizsmbZda5Xtmv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
docs/index.htmlloads the Redoc UI library directly from a CDN with no integrity check:Without a Subresource Integrity (SRI) hash, the browser accepts whatever bytes the CDN returns. A CDN-side compromise, cache poisoning, or accidental package mutation would silently execute malicious JavaScript in the browsers of every developer who visits the API docs site — with full access to the page's DOM and any credentials visible there.
Fix
Add an
integrityattribute (SHA-384, computed from the live bundle) and the requiredcrossorigin="anonymous"attribute:The browser now verifies the script's byte-for-byte hash before executing it. Any deviation — tampered CDN, wrong version, partial response — causes the browser to block the script entirely rather than run it.
The hash was computed directly from the published bundle:
Impact
🤖 Generated with Claude Code
https://claude.ai/code/session_01XXMsynQpRizsmbZda5Xtmv
Generated by Claude Code