Skip to content

🐛 fix substring cache-origin check in getTemplateProxyUrl_ - #40560

Open
mrdevel2002-ui wants to merge 2 commits into
ampproject:mainfrom
mrdevel2002-ui:a4a-template-proxy-origin-check
Open

mrdevel2002-ui wants to merge 2 commits into
ampproject:mainfrom
mrdevel2002-ui:a4a-template-proxy-origin-check

Conversation

@mrdevel2002-ui

Copy link
Copy Markdown

getTemplateProxyUrl_ decides whether an a4a template URL is already on the AMP cache with loc.origin.indexOf(cdnUrlSuffix) > 0, so any origin that merely contains cdn.ampproject.org passes and the URL gets fetched as-is instead of being rewritten to the cache proxy form. templateUrl comes straight out of the ad server JSON response (TemplateValidator.validate and AmpAdNetworkAdzerkImpl.maybeValidateAmpCreative), so a creative can point it at https://cdn.ampproject.org.adserver.example/t.html and have arbitrary HTML from its own origin parsed by getAmpAdMetadata and rendered as the creative in the friendly iframe, which is a plain suffix-confusion bypass of the host check (the fetch is mode: cors, credentials: omit, so the attacker host only needs an ACAO header). isProxyOrigin() anchors the origin against cdnProxyRegex and still accepts both the bare cache host and the <publisher>.cdn.ampproject.org form, so legitimate template URLs behave exactly as before; the added test pins the lookalike host to the proxy rewrite.

@CLAassistant

CLAassistant commented Oct 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ mrdevel2002-ui
❌ erwinmombay
You have signed the CLA already but the status is still pending? Let us recheck it.

@mrdevel2002-ui

Copy link
Copy Markdown
Author

gentle ping

@erwinmombay erwinmombay self-assigned this Nov 4, 2026
@erwinmombay

Copy link
Copy Markdown
Member

looking

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.

3 participants