Skip to content

🐛 Anchor ALLOWED_FONT_REGEX in a4a head validation#40530

Open
madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:a4a-font-regex-anchor
Open

🐛 Anchor ALLOWED_FONT_REGEX in a4a head validation#40530
madib06ops wants to merge 1 commit into
ampproject:mainfrom
madib06ops:a4a-font-regex-anchor

Conversation

@madib06ops

Copy link
Copy Markdown

handleLink gates ad-creative <link rel=stylesheet> hrefs with ALLOWED_FONT_REGEX.test(href), but the regex has no start/end anchors so test() succeeds on any href that merely contains an allowlisted provider, e.g. https://evil.example/x.css#https://fast.fonts.net/, which then survives head sanitization and gets preloaded from the host document. The validator that defines this allowlist (LINK_FONT_STYLESHEET in validator-main.protoascii) matches it with RE2::FullMatch against the whole value, so wrap the alternation in ^(?:...)$ to match that. Added a regression test for a foreign origin that embeds a provider substring.

@CLAassistant

CLAassistant commented Jul 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants