fix(pages): reject devtools:// URLs in navigate_page and new_page (#2935) (#3128)

Reject navigations to `devtools:` URLs. The rejection is unconditional:
no flag or option enables `devtools:` navigations.

The check is in `validateUrl` in `src/utils/url.ts`. These tools call
`validateUrl` and reject `devtools:` URLs:

- `navigate_page` (`src/tools/pages.ts`)
- `new_page` (`src/tools/pages.ts`)
- the slim `navigate` tool (`src/tools/slim/tools.ts`)

The error message is `Navigating to devtools: URLs is not allowed.`

Closes #2935

---------

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
This commit is contained in:
Yuri (IURII) TrukhinandAlex Rudenko authored and GitHub committed 2026-10-20 15:09:45 +00:00
1 parent df14fcc1c7
commit c94c03deda
2 files changed
+15

No files matched your search

+4
View File
@@ -264,6 +264,10 @@ export function validateUrl(url: string, options: ValidateUrlOptions): URL {
);
}
if (parsed.protocol === 'devtools:') {
throw new Error(`Navigating to devtools: URLs is not allowed.`);
}
if (!isAllowedUrl(url, {categoryExtensions})) {
if (parsed.protocol === 'chrome-extension:') {
throw new Error(
+11
View File
@@ -318,6 +318,17 @@ describe('validateUrl', () => {
);
});
it('should reject devtools: URLs', () => {
assert.throws(
() =>
validateUrl(
'devtools://devtools/bundled/devtools_app.html',
defaultOptions,
),
/Navigating to devtools: URLs is not allowed\./,
);
});
it('should allow file URLs when fileNavigations is true or omitted', () => {
assert.strictEqual(
validateUrl('file:///tmp/example.txt', defaultOptions).protocol,