Skip to content

Patch 2#69794

Open
istesf wants to merge 1 commit into
angular:mainfrom
istesf:patch-2
Open

Patch 2#69794
istesf wants to merge 1 commit into
angular:mainfrom
istesf:patch-2

Conversation

@istesf

@istesf istesf commented Jul 15, 2026

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Zone.js stores the internal flags UNPATCHED_EVENTS (in events.ts) and
patchEventTarget (in event-target.ts) as string-keyed properties on the
Zone object. Because these keys are plain strings, they can be inherited
from Object.prototype via prototype pollution. An attacker who pollutes
Object.prototype before Zone.js loads can:

  • inject arbitrary event names into the unpatched list, selectively
    disabling change detection for those events (security bypass);
  • set patchEventTarget to true, causing the entire event patching to
    be skipped and the application to become unresponsive (DoS).

Issue Number: N/A

What is the new behavior?

Before reading the flags, we now check that they are own properties of the
Zone object using hasOwnProperty. Inherited values from the prototype
chain are ignored, closing the prototype pollution vector.

The fix is limited to two files:

  • packages/zone.js/lib/common/events.ts
  • packages/zone.js/lib/browser/event-target.ts

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

I manually tested these changes on Zone.js 0.16.2 (latest stable) in a real
browser. Without the patch, polluting Object.prototype with the relevant
keys disabled event tracking as expected. With the patch, the polluted
values are ignored and Angular change detection continues to work normally.
No existing functionality is affected.

This vulnerability was previously reported to Google Bug Hunters (OSS VRP)
and is tracked as issue 524605344. The fix is coordinated with the Angular
team.

@pullapprove
pullapprove Bot requested a review from kirjs July 15, 2026 18:01

export function eventTargetPatch(_global: any, api: _ZonePrivate) {
if ((Zone as any)[api.symbol('patchEventTarget')]) {
// === FIX START: Prevent prototype pollution of patchEventTarget ===

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.

Can we please drop those comments.

Comment thread packages/zone.js/lib/common/events.ts Outdated
const compare = patchOptions?.diff || compareTaskCallbackVsDelegate;

const unpatchedEvents: string[] = (Zone as any)[zoneSymbol('UNPATCHED_EVENTS')];
// === FIX START: Prevent prototype pollution of UNPATCHED_EVENTS ===

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.

Same here.

@JeanMeche

Copy link
Copy Markdown
Member

Can you also please address the linting issues. Thank you.

@angular-robot angular-robot Bot added the area: zones Issues related to zone.js label Jul 16, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 16, 2026
@istesf

istesf commented Jul 16, 2026

Copy link
Copy Markdown
Author

I removed the comments and fixed the linting.

@JeanMeche

Copy link
Copy Markdown
Member

Can you please squuash the commits into a single one. We'd like this change to be a single commit. Thank you.

@JeanMeche JeanMeche added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jul 16, 2026
…chEventTarget Add hasOwnProperty checks before reading internal flags from the Zone object to prevent prototype pollution attacks.
@JeanMeche JeanMeche 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 Jul 16, 2026
@JeanMeche JeanMeche 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 16, 2026
@JeanMeche
JeanMeche removed the request for review from kirjs July 16, 2026 16:26
@pullapprove
pullapprove Bot requested a review from kirjs July 16, 2026 16:27
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: merge The PR is ready for merge by the caretaker labels Jul 21, 2026
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: zones Issues related to zone.js target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants