Repository navigation
馃悰 escape cta-image before interpolating into page-attachment style - #40561
Open
mrdevel2002-ui wants to merge 1 commit into
Open
mrdevel2002-ui wants to merge 1 commit into
mrdevel2002-ui wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The page-attachment outlink/CTA UI renders its
cta-imageinto an inlinestylestring. For single page story ads that value is copied verbatim from the ad creative's meta tags byamp-story-auto-ads(createPageOutlink_viagetStoryAdMetadataFromDoc), so it crosses a trust boundary into the host story page.Repro: serve a single page story ad whose
amp-cta-imagemeta ishttps://x/i.png) !important; position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 2147483647; background: url(//evil. The outlink image chip ends up with those declarations applied, so the creative can overlay the whole story with its owntarget="_top"outlink.Cause:
style={{backgroundImage: ...url(${openImgAttr}) !important...}}is compiled by#core/dom/jsx(babel-plugin-jsx-style-object +jsxStylePropertyString) intosetAttribute('style', ...), which accepts multiple declarations. A)in the URL closes theurl()and the rest becomes new declarations. The same shape appears inrenderOutlinkUI,renderInlineUi, andbuildOutlink_.Fix: add
cssUrl()inamp-story/1.0/utils.js(emits a quotedurl("...")token with",\and newlines escaped) and route all three sinks through it, so the value stays a singlebackground-imagetoken regardless of input. Keeping the fix at the sink covers the ad path and any future caller rather than relying on each caller to pre-sanitize. Added a regression test that aposition/z-indexpayload incta-imageis not parsed as separate declarations on the element.