Skip to content

Meta service allows executable event-handler attributes #70126

Closed

Description

@SkyZeroZx

Which @angular/* package(s) are the source of the bug?

platform-browser

Is this a regression?

No

Description

MetaDefinition allows arbitrary keys, and the Meta service writes those keys directly as attributes on the resulting <meta> element.

Because of that, addTag(), addTags() and updateTag() also allow on* event-handler attributes, even though Angular normally rejects them in template bindings.

For example, addTags() can produce automatic script execution using two metadata entries:

meta.addTags([
  {
    httpEquiv: 'Content-Security-Policy',
    content: "style-src 'none'",
  },
  {
    onsecuritypolicyviolation: 'alert(document.cookie)',
    style: 'color:red',
  },
]);

The first meta activates the CSP. When Angular inserts the second one, its inline style is blocked and Chromium fires securitypolicyviolation on that same element, executing the handler.

updateTag() can also trigger execution automatically when updating an existing meta element:

<meta property="product:price:amount" content="10">
meta.updateTag({
  property: 'product:price:amount',
  content: '10',
  oncontentvisibilityautostatechange:  'alert(document.cookie)',
  style: 'display:block;content-visibility:auto;position:absolute',
});

Once the element is updated, Chromium fires contentvisibilityautostatechange and the event handler runs without user interaction.

Anything else?

#68836 prevents escaping the generated meta selector, but it does not validate the attributes written to the selected or created meta element.

This also seems similar in principle to GHSA-jj27-h5hq-8x99, where another Angular path allowed event-handler attributes that normal Angular validation rejects.

As an additional note, based on a quick GitHub search, allowing custom metadata or loading relatively arbitrary JSON that is later passed to Meta for SEO seems fairly common, especially for social previews, cards and similar metadata.

This also makes sense (or at least for me ) for things like social previews, cards and other SEO metadata, where applications often need to support custom fields rather than a fixed set of values.

Activity

  1. added
    area: security
    on Aug 8, 2026
  2. added this to the needsTriage milestone on Aug 8, 2026
  3. added 2 commits that reference this issue on Aug 8, 2026
    353d3d7
    ae3e39d
  4. added 2 commits that reference this issue on Aug 17, 2026
    7538744
    c19a36c
  5. angular-automatic-lock-bot commented on Oct 21, 2026

    @angular-automatic-lock-bot

    This issue 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.

  6. locked and limited conversation to collaborators on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: security

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions