fix(@angular/build): preserve integrity and crossorigin in autoCsp loader - #33855
Open
alan-agius4 wants to merge 1 commit into
Open
fix(@angular/build): preserve integrity and crossorigin in autoCsp loader#33855alan-agius4 wants to merge 1 commit into
alan-agius4 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the autoCsp utility to preserve the integrity and crossorigin attributes of dynamically loaded scripts, and modernizes the generated loader script by replacing var with const. A critical issue was identified in the Trusted Types policy logic, where scripts.includes(u) is called on an array of arrays, which will always evaluate to false and break the policy; a suggestion was provided to use scripts.some instead.
alan-agius4
force-pushed
the
fix-auto-csp-sri
branch
2 times, most recently
from
August 13, 2026 07:42
bbb86a8 to
d9e505a
Compare
…ader When both `subresourceIntegrity` and `security.autoCsp` are enabled, initial entry scripts had their `<script>` tags replaced with dynamic loader scripts that did not carry over the `integrity` and `crossorigin` attributes. This caused entry scripts to lose SRI validation. We now capture `integrity` and `crossorigin` attributes during auto-CSP processing and pass them to the generated dynamic loader so `s.integrity` and `s.crossOrigin` are assigned to the dynamically created script elements before insertion. Closes angular#33844
alan-agius4
force-pushed
the
fix-auto-csp-sri
branch
from
August 13, 2026 07:56
d9e505a to
da53863
Compare
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.
When both
subresourceIntegrityandsecurity.autoCspare enabled, initial entry scripts had their<script>tags replaced with dynamic loader scripts that did not carry over theintegrityandcrossoriginattributes. This caused entry scripts to lose SRI validation.We now capture
integrityandcrossoriginattributes during auto-CSP processing and pass them to the generated dynamic loader sos.integrityands.crossOriginare assigned to the dynamically created script elements before insertion.Closes #33844