Repository navigation
Fix exchange url injection - #104
Merged
Merged
Conversation
GrapeGreen
approved these changes
Sep 16, 2026
shangl
force-pushed
the
fix-exchange-url-injection
branch
2 times, most recently
from
September 16, 2026 14:18
8b088c6 to
086f960
Compare
Exchange URLs in Web Bundles were constructed by string-concatenating baseURL with relative asset paths derived from on-disk filenames. Because ':' is a legal character in POSIX directory and filenames, an attacker placing a directory structure like 'static/https:/attacker.test/p.js' with an empty baseURL (the default) caused the plugin to add an exchange for 'https:/attacker.test/p.js'. Under WHATWG URL parsing rules, this normalizes to 'https://attacker.test/p.js', embedding an arbitrary foreign-origin exchange into the emitted (and developer-signed) bundle. This patch adds assertExchangeUrlOrigin(exchangeUrl, baseURL) to ensure: - Any exchange URL that parses as an absolute URL has its origin verified against baseURL. - If baseURL is empty or relative, absolute exchange URLs are rejected. - If baseURL is an absolute URL, the protocol, host, and port must match (supporting both standard web schemes and non-standard schemes like isolated-app:). - Relative exchange URLs remain allowed when baseURL is relative or empty. Unit tests are added across shared utilities, rollup plugin, and webpack plugin. Bug: https://b.corp.google.com/issues/530773137
shangl
force-pushed
the
fix-exchange-url-injection
branch
from
September 16, 2026 14:56
086f960 to
fef73dc
Compare
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.
Validate exchange URL origin to prevent injection into signed bundles
Exchange URLs in Web Bundles were constructed by string-concatenating
baseURL with relative asset paths derived from on-disk filenames.
Because ':' is a legal character in POSIX directory and filenames, an
attacker placing a directory structure like 'static/https:/attacker.test/p.js'
with an empty baseURL (the default) caused the plugin to add an exchange
for 'https:/attacker.test/p.js'. Under WHATWG URL parsing rules, this
normalizes to 'https://attacker.test/p.js', embedding an arbitrary
foreign-origin exchange into the emitted (and developer-signed) bundle.
This patch adds assertExchangeUrlOrigin(exchangeUrl, baseURL) to ensure:
against baseURL.
(supporting both standard web schemes and non-standard schemes like
isolated-app:).
Unit tests are added across shared utilities, rollup plugin, and webpack plugin.
Bug: 530773137