fix(aggregator): pin home page Prism assets with Subresource Integrity - #8046
Open
yhabib wants to merge 2 commits into
Open
fix(aggregator): pin home page Prism assets with Subresource Integrity#8046yhabib wants to merge 2 commits into
yhabib wants to merge 2 commits into
Conversation
The home page loaded prism.min.js and its theme from the Juno CDN over the .raw.icp0.io gateway. A raw response is a single-replica query response with no certification, and the tags carried no integrity attribute. Nothing verified the bytes, so a substituted script could control the whole page. Both tags now use the certified .icp0.io gateway and carry an SHA-384 integrity hash plus crossorigin="anonymous". The CDN sends Access-Control-Allow-Origin: *, so the CORS fetch succeeds. A new unit test asserts that every external script and stylesheet on the home page has an integrity hash, has crossorigin="anonymous", and does not use a raw gateway host.
…tionary The changelog entry for the Subresource Integrity fix fails the CI spelling job. scripts/spellcheck-changelog rejects both words.
|
✅ No security or compliance issues detected. Reviewed everything up to 39db1d1. Security Overview
Detected Code Changes
|
Contributor
There was a problem hiding this comment.
🟢 Approved
The changes correctly add SRI pinning and a regression test without introducing functional or safety issues in the reviewed code paths.
Pull request overview
This PR hardens the SNS aggregator home page’s third-party Prism assets by switching to a certified gateway and pinning the exact bytes via Subresource Integrity (SRI), with a unit test to prevent regressions.
Changes:
- Switched Prism CSS/JS URLs from the
.raw.icp0.iogateway to the certified.icp0.iogateway and addedintegrity+crossorigin="anonymous"attributes. - Added a unit test that scans
index.htmlto ensure all external<script>/<link>resources are SRI-pinned and not loaded from a.raw.host. - Updated changelog (Security) and spellcheck dictionary for new wording.
File summaries
| File | Description |
|---|---|
| rs/sns_aggregator/src/index.html | Pins Prism CDN resources via SRI and uses the certified gateway; adds documentation comments for updating hashes. |
| rs/sns_aggregator/src/assets/tests.rs | Adds a unit test to enforce SRI + certified gateway for external scripts/stylesheets on the home page. |
| rs/sns_aggregator/src/assets.rs | Wires the new test module behind #[cfg(test)]. |
| CHANGELOG-Sns_Aggregator.md | Records the security fix under Unreleased. |
| .config/spellcheck.dic | Adds new words needed by the changelog entry. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Motivation
The aggregator home page loaded Prism's script and stylesheet from a third-party Juno CDN canister over the raw
.raw.icp0.iogateway, with no integrity check.A raw response is a single-replica query, not a certified response, so a dishonest replica could serve different bytes and the browser would run them with no warning.
Changes
<link>and the<script>tags inrs/sns_aggregator/src/index.htmlfrom.raw.icp0.ioto the certified.icp0.iogateway.integrity="sha384-..."andcrossorigin="anonymous"to both tags, so the browser rejects any content that does not match the pinned Prism 1.29.0 / prism-themes 1.9.0 bytes.home_page_pins_every_external_script_and_stylesheet, that scansindex.htmland fails if a<script>or<link>tag loads anhttps://resource without anintegrityandcrossoriginattribute, or uses a.raw.host.Subresourceandstylesheetto.config/spellcheck.dicfor the new changelog line.CHANGELOG-Sns_Aggregator.md/Unreleased/Security.Both hashes were verified against a second source, cdnjs, and both files are byte-identical:
prism-vsc-dark-plus.min.cssUavePWn2zyHuZbvVQRu5n4XEhCiueqts8YR0Dqq1mnsearU03Jfxl1XSHffMI1kqprism.min.js06z5D//U/xpvxZHuUz92xBvq3DqBBFi7Up53HRrbV7Jlv7Yvh/MZ7oenfUe9iCEtTests
cargo test -p sns_aggregatorcovers the newassets::tests::home_page_pins_every_external_script_and_stylesheettest, which fails onmain(missingintegrity) and passes on this branch. Verified with 4 mutations: a full revert, a droppedcrossorigin, a droppedintegrity, and a.raw.host, all fail the test../scripts/lint-rs,cargo test, andcargo spellcheck -- --code 1all pass.scripts/spellcheck-changelog(the CIspellingjob's second step) fails onmain's dictionary and passes with the new.config/spellcheck.dicentries.Todos
index.htmlnames the exactcurl | opensslcommand to recompute it.