Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(compiler): strip namespaced SVG script elements during template compilation - #68689

Merged
leonsenft merged 2 commits into
angular:mainfrom
alan-agius4:svg-script
May 19, 2026
Merged

fix(compiler): strip namespaced SVG script elements during template compilation#68689
leonsenft merged 2 commits into
angular:mainfrom
alan-agius4:svg-script

Conversation

@alan-agius4

Copy link
Copy Markdown
Contributor

Ensures that namespaced <script> elements (such as :svg:script) are correctly classified as PreparsedElementType.SCRIPT by the template preparser and stripped during compilation to prevent potential XSS vulnerabilities. Consequently, obsolete security schema mappings and runtime sanitization checks for <script> attributes have been removed since these elements are never present in compiled template outputs.

Also corrects a truthiness evaluation bug in the runtime sanitization unit tests.

Closes #68642

@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 12, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review May 12, 2026 11:38
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label May 12, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 12, 2026
@pullapprove
pullapprove Bot requested a review from josephperrott May 12, 2026 11:38
@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label May 12, 2026
@alan-agius4
alan-agius4 force-pushed the svg-script branch 4 times, most recently from 82cdc6c to ff91288 Compare May 12, 2026 12:55

@josephperrott josephperrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: fw-security

]);
Object.entries(schema).forEach(([key, context]) => {
if (context === SecurityContext.URL || SecurityContext.RESOURCE_URL) {
if (context === SecurityContext.URL || context === SecurityContext.RESOURCE_URL) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😱

@alxhub alxhub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed-for: fw-general, fw-compiler, fw-security

Comment thread packages/compiler/src/schema/dom_security_schema.ts Outdated
@alan-agius4 alan-agius4 removed the action: review The PR is still awaiting reviews from at least one requested reviewer label May 13, 2026
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label May 13, 2026
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker labels May 13, 2026
@leonsenft

Copy link
Copy Markdown
Contributor

@alan-agius4 there are merge conflicts, please relabel once resolved.

@leonsenft leonsenft added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: merge The PR is ready for merge by the caretaker labels May 18, 2026
@alan-agius4 alan-agius4 removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label May 19, 2026
…ompilation

Ensures that namespaced <script> elements (such as :svg:script) are correctly classified as PreparsedElementType.SCRIPT by the template preparser and stripped during compilation to prevent potential XSS vulnerabilities. Consequently, obsolete security schema mappings and runtime sanitization checks for <script> attributes have been removed since these elements are never present in compiled template outputs.

Also corrects a truthiness evaluation bug in the runtime sanitization unit tests.

Closes angular#68642
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label May 19, 2026
@leonsenft
leonsenft merged commit 90494cd into angular:main May 19, 2026
20 checks passed
@leonsenft

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

@alan-agius4
alan-agius4 deleted the svg-script branch May 19, 2026 20:29
pull Bot pushed a commit to soloinovator/angular that referenced this pull request May 20, 2026
angular#68689 recently updated the compiler
schema which should be kept in sync with the core schema. Fix applied by
running `pnpm bazel run //packages/core:dom_security_schema`.
leonsenft added a commit that referenced this pull request May 20, 2026
#68689 recently updated the compiler
schema which should be kept in sync with the core schema. Fix applied by
running `pnpm bazel run //packages/core:dom_security_schema`.
@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jun 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG <script> and [innerHTML]/[textContent] text can execute in Angular templates

7 participants