


























@@ -3,7 +3,6 @@ import {
33matchesHostnameAllowlist,
44normalizeHostname,
55} from "openclaw/plugin-sdk/browser-security-runtime";
6-import { hasProxyEnvConfigured } from "../infra/net/proxy-env.js";
76import {
87isPrivateNetworkAllowedByPolicy,
98resolvePinnedHostnameWithPolicy,
@@ -32,17 +31,26 @@ export class InvalidBrowserNavigationUrlError extends Error {
32313332export type BrowserNavigationPolicyOptions = {
3433ssrfPolicy?: SsrFPolicy;
34+browserProxyMode?: BrowserNavigationProxyMode;
3535};
363637+export type BrowserNavigationProxyMode = "direct" | "explicit-browser-proxy";
38+3739export type BrowserNavigationRequestLike = {
3840url(): string;
3941redirectedFrom(): BrowserNavigationRequestLike | null;
4042};
41434244export function withBrowserNavigationPolicy(
4345ssrfPolicy?: SsrFPolicy,
46+opts?: { browserProxyMode?: BrowserNavigationProxyMode },
4447): BrowserNavigationPolicyOptions {
45-return ssrfPolicy ? { ssrfPolicy } : {};
48+return {
49+ ...(ssrfPolicy ? { ssrfPolicy } : {}),
50+ ...(opts?.browserProxyMode && opts.browserProxyMode !== "direct"
51+ ? { browserProxyMode: opts.browserProxyMode }
52+ : {}),
53+};
4654}
47554856export function requiresInspectableBrowserNavigationRedirects(ssrfPolicy?: SsrFPolicy): boolean {
@@ -109,13 +117,15 @@ export async function assertBrowserNavigationAllowed(
109117);
110118}
111119112-// Browser network stacks may apply env proxy routing at connect-time, which
113-// can bypass strict destination-binding intent from pre-navigation DNS checks.
114-// In strict mode, fail closed unless private-network navigation is explicitly
115-// enabled by policy.
116-if (hasProxyEnvConfigured() && !isPrivateNetworkAllowedByPolicy(opts.ssrfPolicy)) {
120+// Browser proxy routing hides the final connect target from this process.
121+// Only block when the browser profile is known to be proxy-routed; Gateway
122+// provider proxy env alone is not proof of browser page proxy behavior.
123+if (
124+opts.browserProxyMode === "explicit-browser-proxy" &&
125+!isPrivateNetworkAllowedByPolicy(opts.ssrfPolicy)
126+) {
117127throw new InvalidBrowserNavigationUrlError(
118-"Navigation blocked: strict browser SSRF policy cannot be enforced while env proxy variables are set",
128+"Navigation blocked: strict browser SSRF policy cannot be enforced while this browser profile is proxy-routed",
119129);
120130}
121131@@ -188,6 +198,7 @@ export async function assertBrowserNavigationRedirectChainAllowed(
188198 url,
189199lookupFn: opts.lookupFn,
190200ssrfPolicy: opts.ssrfPolicy,
201+browserProxyMode: opts.browserProxyMode,
191202});
192203}
193204}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。