Skip to content

fix(core): prevent prototype pollution via jsaction attribute parsing#69159

Draft
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/core_jsaction_pollution
Draft

fix(core): prevent prototype pollution via jsaction attribute parsing#69159
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/core_jsaction_pollution

Conversation

@arturovt
Copy link
Copy Markdown
Contributor

@arturovt arturovt commented Jun 4, 2026

The jsaction attribute parser in parseActions previously stored event-action mappings in a plain object ({}) and used event type strings from DOM attributes directly as property keys. This meant that specially crafted event names such as __proto__, constructor, or prototype could interact with the object's prototype chain rather than behaving as ordinary data keys.

The module-level parseCache had a similar issue. It was also implemented as a plain object keyed by the raw jsaction attribute value, allowing special property names to collide with built-in object properties.

This change hardens both code paths by:

  • Replacing actionMap = {} with Object.create(null), creating an object with no prototype chain.
  • Replacing parseCache = {} with Object.create(null) for the same reason.

The `jsaction` attribute parser in `parseActions` previously stored event-action mappings in a plain object (`{}`) and used event type strings from DOM attributes directly as property keys. This meant that specially crafted event names such as `__proto__`, `constructor`, or `prototype` could interact with the object's prototype chain rather than behaving as ordinary data keys.

The module-level `parseCache` had a similar issue. It was also implemented as a plain object keyed by the raw `jsaction` attribute value, allowing special property names to collide with built-in object properties.

This change hardens both code paths by:

* Replacing `actionMap = {}` with `Object.create(null)`, creating an object with no prototype chain.
* Replacing `parseCache = {}` with `Object.create(null)` for the same reason.
@angular-robot angular-robot Bot added area: core Issues related to the framework runtime requires: TGP This PR requires a passing TGP before merging is allowed labels Jun 4, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime requires: TGP This PR requires a passing TGP before merging is allowed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant