Skip to content

fix(platform-browser): reject event-handler attributes in Meta service - #70166

Closed
RubenPari wants to merge 1 commit into
angular:mainfrom
RubenPari:fix/meta-onstar-attributes
Closed

RubenPari wants to merge 1 commit into
angular:mainfrom
RubenPari:fix/meta-onstar-attributes

Conversation

@RubenPari

Copy link
Copy Markdown

Summary

  • Fixes Meta service allows executable event-handler attributes #70126.
  • MetaDefinition has an open index signature, so addTag/addTags/updateTag accept arbitrary keys, including on* event-handler attributes (e.g. onsecuritypolicyviolation, oncontentvisibilityautostatechange). setMetaElementAttributes() wrote every key straight onto the <meta> element via setAttribute() with no validation, so these execute without user interaction once the element updates (see repro in the issue).
  • Skip keys starting with on (case-insensitive) before writing the attribute, matching the stance Angular already takes for property bindings in validateAgainstEventProperties() (packages/core/src/sanitization/sanitization.ts).

Test plan

  • Added two cases to packages/platform-browser/test/browser/meta_spec.ts: addTags with an onerror/mixed-case OnClick key, and updateTag with onsecuritypolicyviolation, asserting the attribute is never written.
  • bazel test //packages/platform-browser/test:test — passing.

setMetaElementAttributes() wrote every key of a MetaDefinition
straight onto the <meta> element via setAttribute(), with no
validation. MetaDefinition's open index signature ([prop: string]:
string) means addTag()/addTags()/updateTag() accept arbitrary keys,
including on* event-handler attributes (e.g. onsecuritypolicyviolation,
oncontentvisibilityautostatechange), which browsers execute without
user interaction once the meta element updates.

Skip keys starting with 'on' (case-insensitive), matching the same
security stance Angular already takes for property bindings in
validateAgainstEventProperties().
@pullapprove
pullapprove Bot requested a review from atscott August 12, 2026 20:56
@google-cla

google-cla Bot commented Aug 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Aug 12, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 12, 2026
@JeanMeche

Copy link
Copy Markdown
Member

Thanks for the contribution, but we're already looking at #70127. Please provide feedback there.

@JeanMeche JeanMeche closed this Aug 12, 2026
@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 Oct 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: core Issues related to the framework runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Meta service allows executable event-handler attributes

2 participants