Skip to content

Refactor HTTP egress around external proxy enforcement - #91722

Closed
joshavant wants to merge 16 commits into
mainfrom
remove-internal-fetch-ssrf-guard
Closed

joshavant wants to merge 16 commits into
mainfrom
remove-internal-fetch-ssrf-guard

Conversation

@joshavant

@joshavant joshavant commented Jun 9, 2026 •

Copy link
Copy Markdown
Collaborator

Note from Dallin: this may be a good change, but likely should be split up. My agent went rogue and closed it but I think best to leave closed for now

Summary

This PR replaces OpenClaw's old in-process SSRF fetch guard architecture with a smaller HTTP egress model:

  • proxy.enabled=true plus an operator-managed external proxy is the high-assurance SSRF and egress-control boundary.
  • OpenClaw no longer maintains the broad fetchWithSsrFGuard / DNS pinning / per-call SSRF policy framework as a public plugin SDK or app-wide fetch API.
  • Stock direct mode still keeps a narrow guard for OpenClaw-owned fetches of arbitrary untrusted URLs.
  • App-owned outbound HTTP mechanics are centralized through the egress helper instead of repeated local fetch loops.

What Changed

  • Added the canonical HTTP egress helper in src/infra/net/egress-fetch.ts.
  • Migrated OpenClaw-owned runtime fetch paths, including web fetch, media/input URL fetches, link understanding, citation redirects, marketplace archive downloads, skill install downloads, MCP HTTP, provider transport fetches, and related provider/plugin runtime fetches.
  • Removed the old fetchWithSsrFGuard API and retired old per-call SSRF policy/config knobs.
  • Removed public SSRF SDK surfaces as a breaking SDK cleanup:
    • openclaw/plugin-sdk/ssrf-runtime
    • openclaw/plugin-sdk/ssrf-policy
    • openclaw/plugin-sdk/ssrf-dispatcher
    • SSRF/network-policy helper re-exports from public SDK runtime surfaces
  • Kept broad network-policy/DNS-pinning/private-network helper facades out of the final Plugin SDK surface, including private-local SDK subpaths.
  • Trimmed bundled-plugin owner-local network helpers so they keep only the behavior each owner actually uses, rather than copying a generic network-policy facade under local names.
  • Replaced the old raw-fetch guard script with scripts/check-runtime-http-egress-boundary.mjs, which blocks raw app-owned runtime fetches, retired SSRF guard vocabulary, and broad new Plugin SDK network-policy facades.
  • Updated docs, doctor migrations, package/export checks, and Plugin SDK contract tests for the new boundary.

Behavior

When proxy.enabled=false, OpenClaw's untrusted URL helper rejects local/private/internal targets for OpenClaw-owned arbitrary URL fetches by default, including localhost, loopback, link-local, RFC1918 private networks, known metadata hosts, DNS results resolving to blocked ranges, and redirect targets resolving to blocked ranges.

This direct-mode check is a narrow stock safety guard. It is not a complete SSRF defense and is not a substitute for an external egress proxy in high-assurance deployments.

When proxy.enabled=true, OpenClaw routes app-owned HTTP egress through the configured proxy and does not try to duplicate the proxy's comprehensive destination policy in application code.

Operator-configured endpoints, fixed product/vendor endpoints, and transport-owned fetch behavior are treated separately from arbitrary untrusted web URLs.

Breaking Changes

  • Plugins can no longer import the removed SSRF SDK subpaths or fetchWithSsrFGuard / GUARDED_FETCH_MODE style APIs.
  • Plugins should use ordinary fetch or supported generic fetch runtime mechanics where appropriate.
  • High-assurance destination policy belongs at proxy.enabled=true plus the operator-managed external proxy.
  • Plugin-specific allowlist validation should stay local to the plugin when the plugin owns a special protocol, redirect flow, or local/private service opt-in.

Out Of Scope

This PR does not claim full SSRF coverage for Browser/CDP, subprocesses, sandbox executors, Docker/SSH boundaries, MCP stdio children, native addons, or non-Node transport libraries. Those remain separate defense-in-depth follow-ups.

Verification

Focused local checks

  • node scripts/check-runtime-http-egress-boundary.mjs
  • node scripts/check-plugin-sdk-subpath-exports.mjs
  • git diff --check
  • pnpm docs:check-mdx
  • pnpm build
  • pnpm tsgo:extensions
  • node scripts/run-vitest.mjs test/scripts/check-runtime-http-egress-boundary.test.ts
  • node scripts/run-vitest.mjs src/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.ts src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts src/plugins/contracts/plugin-sdk-subpaths.test.ts
  • node scripts/run-vitest.mjs src/plugins/contracts/extension-package-project-boundaries.test.ts src/plugins/contracts/package-manifest.contract.test.ts test/extension-package-tsc-boundary.test.ts test/scripts/check-extension-package-tsc-boundary.test.ts
  • Focused Vitest coverage for the egress helper, migrated fetch paths, plugin SDK contracts, doctor migrations, package/release checks, Browser, Matrix, Tlon, LINE, Zalo, Synology Chat, MS Teams, Brave, Firecrawl, SearXNG, LM Studio, Google Meet, Nostr, Voice Call, QQBot, Telegram, and Codex sandbox HTTP.
  • .agents/skills/autoreview/scripts/autoreview --mode local: clean, no accepted/actionable findings.

Package smoke

  • Provider/id: blacksmith-testbox, tbx_01ktnh39xjqvzaqyvnk4tek7bf
  • Actions run: 27188175859
  • Verified the packaged SDK/public export surface after the SDK cleanup.
  • Confirmed retired SSRF SDK/runtime exports are absent from the public package surface.

External proxy E2E

  • Provider/id: blacksmith-testbox, tbx_01ktnh8w3mgdvg1rgvd8z4tmr8
  • Actions run: 27188302520
  • Verified proxy.enabled=true routes covered runtime fetches through the configured external proxy.
  • Verified proxy-mode fetch and redirect behavior remains intact for the covered helper scenarios.

AWS product-path proof

  • Provider/id: aws, cbx_5b6e8d6f5c94
  • Exercised OpenClaw product call paths against an AWS-hosted target, honeypot, and proof proxy fixture:
    • web_fetch
    • link understanding
    • citation redirect resolution
    • remote media fetch
    • input-file URL fetch
    • marketplace archive download
    • skill install download
    • MCP HTTP same-origin fetch
    • operator-configured endpoint fetch
  • Verified direct-mode untrusted URL paths block private/local/metadata-style targets before honeypot access.
  • Verified proxy-mode paths route through the proof proxy and apply proxy allow/block decisions.
  • Verified operator-configured endpoint behavior remains distinct from arbitrary untrusted URL behavior.

Marketplace private-redirect proof

  • Provider/id: aws, cbx_9bd99a3d87b9
  • AWS runs: run_b117a76160d3, run_714cc4109634, run_b47458f97c57, run_62972875e8be, run_636a90f349b7, run_0058dee2fdac
  • Verified archive-looking marketplace source URLs enter the archive download path, then block private redirect targets in direct mode before honeypot access.
  • Verified proxy mode routes the same redirect flow through the proof proxy, where the public archive fixture is allowed and the private redirect target is blocked.
  • Honeypot hits remained 0 for the private redirect target in both modes.

Real Behavior Proof

Behavior addressed: OpenClaw-owned arbitrary URL fetch paths no longer depend on the old scattered fetchWithSsrFGuard architecture, while stock direct mode still blocks local/private/metadata-style targets for untrusted URL fetches.

Real environment tested: Local focused tests, Blacksmith Testbox, and AWS Crabbox live network topology proof.

Exact steps or command run after this patch: Focused test lanes, runtime egress boundary check, package smoke, external proxy E2E, AWS product-path proof, targeted marketplace archive redirect proof, docs check, build, typecheck, and autoreview.

Evidence after fix: Direct-mode untrusted URL fetches block private redirect targets before honeypot access; proxy-mode fetches route through the external proof proxy and are blocked by proxy policy before honeypot access. Retired SSRF SDK/runtime surfaces are absent from package exports and broad network-policy facades are guarded against reintroduction.

Observed result after fix: All planned proof rows passed for this refactor's stated scope.

What was not tested: Browser/CDP, subprocess, sandbox executor, Docker, SSH, MCP stdio, native addon, and non-Node transport boundaries.

@joshavant
joshavant requested a review from a team as a code owner June 9, 2026 14:52
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: zalo Channel integration: zalo gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: openai extensions: minimax extensions: byteplus extensions: huggingface extensions: moonshot extensions: together extensions: volcengine extensions: xiaomi labels Jun 9, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 9, 2026
@joshavant
joshavant marked this pull request as draft June 9, 2026 15:10
@joshavant
joshavant force-pushed the remove-internal-fetch-ssrf-guard branch from 6a47e0e to b400f90 Compare June 9, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: qa-channel Channel integration: qa-channel channel: qqbot channel: signal Channel integration: signal channel: slack Channel integration: slack channel: sms Channel integration: sms channel: synology-chat channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: zalo Channel integration: zalo cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: brave extensions: byteplus extensions: chutes extensions: codex extensions: deepinfra extensions: elevenlabs extensions: fal extensions: firecrawl extensions: github-copilot extensions: google extensions: gradium extensions: huggingface extensions: inworld Extension: inworld extensions: kilocode extensions: litellm extensions: lmstudio extensions: microsoft extensions: minimax extensions: mistral extensions: moonshot extensions: nvidia extensions: ollama extensions: openai extensions: openrouter extensions: policy extensions: qa-lab extensions: thread-ownership extensions: together extensions: venice extensions: vercel-ai-gateway extensions: volcengine extensions: xai extensions: xiaomi gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: azure-speech Azure Speech plugin plugin: google-meet plugin: pixverse proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security Security documentation size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants