Skip to content

🐛 match only real subdomains in linker isDomainMatch_ default - #40572

Open
mrdevel2002-ui wants to merge 1 commit into
ampproject:mainfrom
mrdevel2002-ui:linker-subdomain-wildcard
Open

mrdevel2002-ui wants to merge 1 commit into
ampproject:mainfrom
mrdevel2002-ui:linker-subdomain-wildcard

Conversation

@mrdevel2002-ui

Copy link
Copy Markdown

When a linker config leaves out destinationDomains, isDomainMatch_ falls back to [highestAvailableDomain, '*' + highestAvailableDomain], and isWildCardMatch turns *example.com into ^.*example\.com$, so separately registrable lookalikes like evilexample.com or not-example.com match too. That is the path the linker docs' own example takes (proxyOnly: false, no destinationDomains) and the one AMP cache pages hit with amp-cookie-scope, so a link or amp-form target on the page pointing at an attacker-registered lookalike gets the linker param appended on click, which for GA is _gl carrying the user's _ga client ID. Prefixing the wildcard with *. keeps every real subdomain matching (the bare domain is still the first entry) and lines up with the *.example.com form the docs describe; the default-subdomain test now also covers a lookalike host and a nested subdomain.

With no destinationDomains, isDomainMatch_ fell back to
'*' + highestAvailableDomain, which isWildCardMatch compiles to
^.*example\.com$ and so also matched lookalike registrable domains
such as evilexample.com, appending linker IDs to links pointing there.

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