mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 03:12:42 +00:00
fix(browser): block non-network navigation schemes
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
} from "../infra/net/ssrf.js";
|
||||
|
||||
const NETWORK_NAVIGATION_PROTOCOLS = new Set(["http:", "https:"]);
|
||||
const SAFE_NON_NETWORK_URLS = new Set(["about:blank"]);
|
||||
|
||||
export class InvalidBrowserNavigationUrlError extends Error {
|
||||
constructor(message: string) {
|
||||
@@ -42,7 +43,12 @@ export async function assertBrowserNavigationAllowed(
|
||||
}
|
||||
|
||||
if (!NETWORK_NAVIGATION_PROTOCOLS.has(parsed.protocol)) {
|
||||
return;
|
||||
if (SAFE_NON_NETWORK_URLS.has(parsed.href)) {
|
||||
return;
|
||||
}
|
||||
throw new InvalidBrowserNavigationUrlError(
|
||||
`Navigation blocked: unsupported protocol "${parsed.protocol}"`,
|
||||
);
|
||||
}
|
||||
|
||||
await resolvePinnedHostnameWithPolicy(parsed.hostname, {
|
||||
|
||||
Reference in New Issue
Block a user