Skip to content

fix(url): unwrap view-source: before all scheme checks in validateUrl - #3335

Merged
Lightning00Blade merged 3 commits into
ChromeDevTools:mainfrom
kakashi-kx:fix/view-source-scheme-bypass
Nov 10, 2026
Merged

Lightning00Blade merged 3 commits into
ChromeDevTools:mainfrom
kakashi-kx:fix/view-source-scheme-bypass

Conversation

@kakashi-kx

Copy link
Copy Markdown
Contributor

Summary

validateUrl() only unwrapped a view-source: prefix when checking for the file: scheme (via targetsFileScheme()). The devtools: check and the chrome:/chrome-untrusted:/chrome-extension: block inside isAllowedUrl() were evaluated against the outer URL, so a view-source:-prefixed URL to those schemes passed validation unchanged. Chrome resolves view-source: wrapping (including nested wrapping) at navigation time and loads the page under the wrapped URL's own origin.

Fix

Generalizes the unwrap into unwrapViewSource(), bounded the same way targetsFileScheme() was (handles nested view-source:view-source:... up to 5 levels, matching existing test coverage), and runs every scheme check in validateUrl against the unwrapped target. targetsFileScheme() is removed as it's now subsumed.

Testing

All 41 existing + new tests pass (npx node --test build/tests/utils/url.test.js), including the pre-existing nested-wrapper file: test. Added coverage for view-source:-wrapped devtools:, chrome://settings, chrome-untrusted:, and chrome-extension:, plus confirmed chrome://inspect remains reachable via view-source: (intentionally allowlisted, unaffected by this fix).

Related: https://issuetracker.google.com/issues/577446552 (reported via Google OSS VRP, closed as out-of-scope under the Oct 1 2026 supply-chain-only policy change, not disputed on technical grounds).

validateUrl() previously unwrapped a view-source: prefix only when
checking for the file: scheme, via targetsFileScheme(). The devtools:
check and the chrome:/chrome-untrusted:/chrome-extension: block inside
isAllowedUrl() were evaluated against the outer URL, so a
view-source:-prefixed URL to those schemes passed validation unchanged.
Chrome resolves view-source: wrapping (including nested wrapping) at
navigation time and loads the page under the wrapped URL's own origin.

Generalizes the unwrap into unwrapViewSource(), bounded the same way
targetsFileScheme() was, and runs every scheme check against the
unwrapped target. Adds regression tests for view-source:-wrapped
devtools:, chrome:, chrome-untrusted:, and chrome-extension: URLs.
@google-cla

google-cla Bot commented Oct 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@kakashi-kx

Copy link
Copy Markdown
Contributor Author

recheck

@kakashi-kx
kakashi-kx marked this pull request as ready for review October 24, 2026 18:07

@kakashi-kx kakashi-kx left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recheck

@kakashi-kx kakashi-kx left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@Lightning00Blade
Lightning00Blade self-requested a review November 9, 2026 16:05

@mangeshraut712 mangeshraut712 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran validateUrl from this head (04eca69) under Node 24 with fileNavigations: false against a few inputs. The fix does what it says for one to five levels of wrapping: view-source:chrome://settings and the same URL wrapped five times are both rejected with Navigating to chrome: URLs is not allowed.

One gap, noted inline: at six levels the loop stops while current is still view-source:, and every check below then runs against view-source:. So these two are accepted:

ALLOWED 'view-source:'.repeat(6) + 'chrome://settings'   -> view-source:
ALLOWED 'view-source:'.repeat(6) + 'file:///etc/passwd'  -> view-source:

The file: case was already reachable through the old targetsFileScheme on main, so this isn't new, but this PR is the natural place to close it since it now routes every scheme check through unwrapViewSource.

A smaller behaviour change, just so it's deliberate: view-source:example.com used to pass (targetsFileScheme returned false when the inner new URL threw). It now fails with The view-source: wrapped content is not a valid URL. That seems fine to me, but it might be worth a test so the change is visible.

Comment thread src/utils/url.ts Resolved
@kakashi-kx

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @mangeshraut712, and for testing against the head commit.

You're right about the depth gap. The bounded loop could exit with current still view-source:, so anything nested past the limit skipped the downstream scheme checks. I've changed it to fail closed:

 return current.protocol === 'view-source:' ? null : current;

Over-nested input now hits the existing "wrapped content is not a valid URL" error, whatever the depth.

I also added tests for:

  • 6-level view-source: wrapping around chrome://settings
  • 6-level wrapping around file:///etc/passwd
  • view-source:example.com, so the behaviour change you flagged is now deliberate and visible

Pushed in <commit hash>. I've also merged the latest main to clear the out-of-date status.

@Lightning00Blade, this is ready for another look whenever you have time.

@Lightning00Blade

Copy link
Copy Markdown
Collaborator

@kakashi-kx I don't see any commit after @mangeshraut712's message.

@kakashi-kx

Copy link
Copy Markdown
Contributor Author

Thanks @mangeshraut712, fixed in 05d7877. unwrapViewSource now fails closed, so nesting past the limit is rejected at any depth. I added tests for the 6-level chrome:// and file:// cases, a 5-level boundary case, and view-source:example.com

@Lightning00Blade
Lightning00Blade added this pull request to the merge queue Nov 10, 2026
Merged via the queue into ChromeDevTools:main with commit 7275268 Nov 10, 2026
14 checks passed
Lightning00Blade pushed a commit to jaeminbird/chrome-devtools-mcp that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.13.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.12.0...chrome-devtools-mcp-v1.13.0)
(2026-11-11)


### 🎉 Features

* add logpoints built on the DevTools BreakpointManager
([ChromeDevTools#3211](ChromeDevTools#3211))
([0877ee0](ChromeDevTools@0877ee0))
* add page-scoped network mocks
([ChromeDevTools#3384](ChromeDevTools#3384))
([1d692d3](ChromeDevTools@1d692d3))
* support upstream network mock responses
([ChromeDevTools#3420](ChromeDevTools#3420))
([c4bf342](ChromeDevTools@c4bf342))


### 🛠️ Fixes

* **config:** accept config files with a UTF-8 BOM
([ChromeDevTools#3365](ChromeDevTools#3365))
([63170b1](ChromeDevTools@63170b1))
* **console:** stop resolving a cyclic Error.cause chain after 10 causes
([ChromeDevTools#3338](ChromeDevTools#3338))
([172656a](ChromeDevTools@172656a))
* disable set_logpoints when --no-javascript-evaluation is set
([ChromeDevTools#3415](ChromeDevTools#3415))
([11fcc59](ChromeDevTools@11fcc59)),
closes
[ChromeDevTools#3414](ChromeDevTools#3414)
* **extensions:** say list_extensions only lists unpacked extensions
([ChromeDevTools#3433](ChromeDevTools#3433))
([1383bb9](ChromeDevTools@1383bb9))
* ignore an invalid cached version in the update check
([ChromeDevTools#3392](ChromeDevTools#3392))
([3a9f378](ChromeDevTools@3a9f378))
* **input:** validate press_key and submitKey parameters in Zod schema
([ChromeDevTools#3382](ChromeDevTools#3382))
([375a269](ChromeDevTools@375a269))
* **network:** start an empty request list for navigations without a
request
([ChromeDevTools#3357](ChromeDevTools#3357))
([b701776](ChromeDevTools@b701776))
* normalize non-Error values thrown by tool handlers
([ChromeDevTools#3068](ChromeDevTools#3068))
([535a3dc](ChromeDevTools@535a3dc))
* **performance:** error when performance_stop_trace is called on a
non-recording page
([ChromeDevTools#2971](ChromeDevTools#2971))
([ChromeDevTools#3117](ChromeDevTools#3117))
([1ab630a](ChromeDevTools@1ab630a))
* **plugin:** launch the Claude Code MCP server with npx --prefix
([ChromeDevTools#3353](ChromeDevTools#3353))
([a24334d](ChromeDevTools@a24334d))
* preserve task serialization on request cancellation
([ChromeDevTools#3079](ChromeDevTools#3079))
([03fd4e8](ChromeDevTools@03fd4e8))
* report page loads that keep the URL
([ChromeDevTools#3395](ChromeDevTools#3395))
([3cc38bb](ChromeDevTools@3cc38bb))
* save binary request bodies byte for byte
([ChromeDevTools#3404](ChromeDevTools#3404))
([e3eb901](ChromeDevTools@e3eb901))
* suggest --headless when Chrome cannot find an X server
([ChromeDevTools#3428](ChromeDevTools#3428))
([8b0856a](ChromeDevTools@8b0856a))
* **url:** unwrap view-source: before all scheme checks in validateUrl
([ChromeDevTools#3335](ChromeDevTools#3335))
([7275268](ChromeDevTools@7275268))
* **wait:** explain whitespace-sensitive text matching
([ChromeDevTools#3350](ChromeDevTools#3350))
([81a0379](ChromeDevTools@81a0379))


### 📄 Documentation

* add Pi client configuration
([ChromeDevTools#3364](ChromeDevTools#3364))
([bc0d93e](ChromeDevTools@bc0d93e))
* clarify custom browser launch and connection options
([ChromeDevTools#3386](ChromeDevTools#3386))
([7e10c08](ChromeDevTools@7e10c08))
* **input:** note that press_key cannot drive native &lt;select&gt;
popups on macOS
([ChromeDevTools#3288](ChromeDevTools#3288))
([8e79bd0](ChromeDevTools@8e79bd0))


### ⚡ Performance

* **memory:** drop async parents of request initiators in
NetworkCollector
([ChromeDevTools#3345](ChromeDevTools#3345))
([ca6f834](ChromeDevTools@ca6f834)),
closes
[ChromeDevTools#3344](ChromeDevTools#3344)


### 🏗️ Refactor

* re-export only used Zod runtime members from third_party barrel
([ChromeDevTools#3439](ChromeDevTools#3439))
([6b056c8](ChromeDevTools@6b056c8))
* reuse Zod schemas and validate integer viewport dimensions
([ChromeDevTools#3367](ChromeDevTools#3367))
([3c609da](ChromeDevTools@3c609da))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Alex Rudenko <[email protected]>
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