Skip to content

reject on* attributes on AMP elements in validateAttributeChange - #40563

Open
madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:purifier-amp-event-handlers
Open

madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:purifier-amp-event-handlers

Conversation

@madib06ops

Copy link
Copy Markdown
Contributor

Purifier.validateAttributeChange overrides DOMPurify's rejection for any amp-* element and then calls isValidAttr with opt_purify=true, which skips the on* check on the assumption that DOMPurify already did it. amp-script's SanitizerImpl uses this to vet worker mutations, so worker code doing el = document.createElement('amp-img'); el.setAttribute('onclick', 'alert(document.domain)') gets a live inline handler on the main document, escaping the worker sandbox. Reject on* attributes (other than AMP's on) in that override branch, the same rule isValidAttr applies when DOMPurify isn't involved; the new tests in test-purifier.js and test-amp-script.js fail without the change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant