Skip to content

fix(@angular/build): preserve integrity and crossorigin in autoCsp loader - #33855

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-auto-csp-sri
Open

fix(@angular/build): preserve integrity and crossorigin in autoCsp loader#33855
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-auto-csp-sri

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

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 #33844

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/angular/build/src/utils/index-file/auto-csp.ts Outdated
@alan-agius4
alan-agius4 force-pushed the fix-auto-csp-sri branch 2 times, most recently from bbb86a8 to d9e505a Compare August 13, 2026 07:42
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release requires: TGP This PR requires a passing TGP before merging is allowed action: review The PR is still awaiting reviews from at least one requested reviewer and removed requires: TGP This PR requires a passing TGP before merging is allowed labels Aug 13, 2026
@alan-agius4
alan-agius4 requested a review from clydin August 13, 2026 07:43
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autoCsp drops the integrity attribute from entry scripts when subresourceIntegrity is enabled

1 participant