Skip to content

Add Subresource Integrity hash to Redoc CDN script#45

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/elegant-edison-kq8crl
Open

Add Subresource Integrity hash to Redoc CDN script#45
dmchaledev wants to merge 1 commit into
mainfrom
claude/elegant-edison-kq8crl

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Summary

  • docs/index.html loads redoc.standalone.js from the jsDelivr CDN with no Subresource Integrity (SRI) check. If that CDN response were ever tampered with (compromised CDN, cache poisoning, MITM), the browser would silently execute arbitrary JS on the API reference page — including inside Redoc's "Try it" console, where integrators paste live API keys.
  • This adds a pinned integrity="sha384-..." attribute plus crossorigin="anonymous" so the browser refuses to execute the script if the served bytes ever differ from the known-good version.
  • The hash was computed from the actual file served at https://cdn.jsdelivr.net/npm/redoc@2.5.3/bundles/redoc.standalone.js and cross-checked against jsDelivr's own published SHA-256 for that file (data.jsdelivr.com package API) to confirm it's byte-for-byte correct before pinning.

Test plan

  • Verified the downloaded file's SHA-256 matches jsDelivr's own published hash for redoc@2.5.3's bundles/redoc.standalone.js, confirming the file used to derive the SRI hash is authentic and unmodified.
  • Computed SHA-384 of that same file for the integrity attribute.
  • Manual check in a browser with real network access recommended before merge (this session's sandboxed browser had no outbound network access at all, unrelated to this change, so a live Redoc render couldn't be captured here).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ln27LeJd3LfFBkUaCQL6Er


Generated by Claude Code

The docs page loads redoc.standalone.js from jsDelivr with no SRI
check, so a compromised or tampered CDN response would execute
arbitrary JS on the API reference page — including inside Redoc's
"Try it" console where users paste live API keys. Pin the script
with a sha384 integrity hash (verified against jsDelivr's own
published file hash for redoc@2.5.3) so the browser refuses to run
the script if the served bytes ever differ.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln27LeJd3LfFBkUaCQL6Er
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants