Skip to content

🐛 Fix cache-origin check bypass in amp-ad-template-helper#40524

Open
madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:a4a-template-cache-origin-check
Open

🐛 Fix cache-origin check bypass in amp-ad-template-helper#40524
madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:a4a-template-cache-origin-check

Conversation

@madib06ops

Copy link
Copy Markdown

getTemplateProxyUrl_ decides whether a template URL is already an AMP cache URL with loc.origin.indexOf('cdn.ampproject.org') > 0, which is a substring test rather than an origin match. The templateUrl comes from the ad XHR response parsed in template-validator.js, so a value like https://cdn.ampproject.org.evil.example/x passes the check and the template is fetched and rendered straight from the attacker origin instead of being routed through the cache. Switch to isProxyOrigin(loc), which tests the anchored cdnProxyRegex against the whole origin so only real cdn.ampproject.org hosts are treated as already-proxied.

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