Skip to content

fix(cdk/private): guard createPolicy against DOM clobbering - #33410

Merged
crisbeto merged 1 commit into
angular:mainfrom
arturovt:fix/multiple_vulners
Jul 8, 2026
Merged

fix(cdk/private): guard createPolicy against DOM clobbering#33410
crisbeto merged 1 commit into
angular:mainfrom
arturovt:fix/multiple_vulners

Conversation

@arturovt

@arturovtarturovt commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Wraps trustedTypes.createPolicy in a try/catch to handle two failure
cases: the policy name already being registered (e.g. in a micro-frontend
setup), and window.trustedTypes being DOM-clobbered by an HTML element
before Angular bootstraps. In both cases the policy falls back to null,
and trustedHTMLFromString continues to work via plain strings while
sanitization in _setInnerHtml still runs.

@pullapprove
pullapproveBot requested a review from devversionJune 17, 2026 10:13
Comment threadsrc/cdk/private/trusted-types.ts Outdated
Comment threadsrc/cdk/drag-drop/dom/styling.ts Outdated
@arturovt
arturovtforce-pushed the fix/multiple_vulners branch from 39d7c2c to 383bb1aCompareJune 17, 2026 17:27
@arturovtarturovt changed the title fix(multiple): harden extendStyles and trusted-types against prototype pollution and DOM clobberingfix(cdk/private): guard createPolicy against DOM clobberingJun 17, 2026
Comment threadsrc/cdk/private/trusted-types.ts Outdated
policy = ttWindow.trustedTypes.createPolicy('angular#components', {
createHTML: (s: string) => s,
});
} catch {

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.

Maybe we should console.error here so we know it's failing?

Wraps trustedTypes.createPolicy in a try/catch to handle two failure
cases: the policy name already being registered (e.g. in a micro-frontend
setup), and window.trustedTypes being DOM-clobbered by an HTML element
before Angular bootstraps. In both cases the policy falls back to null,
and trustedHTMLFromString continues to work via plain strings while
sanitization in _setInnerHtml still runs.
@arturovt
arturovtforce-pushed the fix/multiple_vulners branch from 383bb1a to 8e592edCompareJune 18, 2026 20:03
@arturovt
arturovt requested a review from crisbetoJune 18, 2026 20:03
@crisbetocrisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jul 8, 2026
@crisbeto
crisbeto merged commit c069cab into angular:mainJul 8, 2026
31 of 34 checks passed
@crisbeto

Copy link
Copy Markdown
Member

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

crisbeto pushed a commit that referenced this pull request Jul 8, 2026
Wraps trustedTypes.createPolicy in a try/catch to handle two failure
cases: the policy name already being registered (e.g. in a micro-frontend
setup), and window.trustedTypes being DOM-clobbered by an HTML element
before Angular bootstraps. In both cases the policy falls back to null,
and trustedHTMLFromString continues to work via plain strings while
sanitization in _setInnerHtml still runs.
(cherry picked from commit c069cab)
@arturovt
arturovt deleted the fix/multiple_vulners branch July 8, 2026 13:01
@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-botangular-automatic-lock-botBot locked and limited conversation to collaborators Aug 8, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: mergeThe PR is ready for merge by the caretakertarget: patchThis PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@arturovt@crisbeto