fix(@angular/build): prevent HTML injection from inlined font CSS#33552
Open
SkyZeroZx wants to merge 1 commit into
Open
fix(@angular/build): prevent HTML injection from inlined font CSS#33552SkyZeroZx wants to merge 1 commit into
SkyZeroZx wants to merge 1 commit into
Conversation
Remote font CSS is embedded into a raw-text style element. Escape closing style tags so a compromised allowlisted response cannot terminate the style element and inject nonce-bearing markup.
There was a problem hiding this comment.
Code Review
This pull request addresses a potential security vulnerability by escaping closing style tags (e.g., </style>) within inlined CSS content to prevent them from prematurely terminating the generated raw-text style element. It also adds a corresponding unit test to verify that closing style tags are correctly escaped and do not lead to arbitrary HTML injection. I have no feedback to provide as there are no review comments.
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.
Remote font CSS is embedded into a raw-text style element. Escape closing style tags so a compromised allowlisted response cannot terminate the style element and inject nonce-bearing markup.
For example, an attacker controlling the CSS response from an allowlisted font provider ,through provider, cache, or trusted HTTPS proxy compromise , could include
</style><script>evil</script>.During a production build, Angular embedded this response inside a
<style>element, turning external CSS into executable first-party JavaScript. If the application used ngCspNonce, later processing also copied the trusted nonce onto the injected script, allowing it to execute under a nonce based CSP. This commit neutralizes closing</style>sequences before embedding the CSS into generated HTML.