Skip to content

fix(web): self-hosted web tool endpoints can redirect requests to other hosts - #196847

Merged
drobison00 merged 1 commit into
openclaw:mainfrom
drobison00:fix/fix-1190
Nov 19, 2026
Merged

drobison00 merged 1 commit into
openclaw:mainfrom
drobison00:fix/fix-1190

Conversation

@drobison00

@drobison00 drobison00 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a self-hosted web tool endpoint (for example a private search instance) can redirect a request to a different host, and the request follows it with private-network access still enabled.

User Impact

User impact: requests to a self-hosted web tool endpoint now stay on the hostname that was configured, on every redirect hop. Configured private endpoints and same-host redirects keep working.

Required action for some deployments: if a self-hosted endpoint relies on redirecting to a different hostname, configure that destination hostname directly. Such redirects are now rejected.

Why This Change Was Made

Self-hosted endpoints need private-network access, but the shared self-hosted policy granted it without restricting the destination hostname. The policy is now derived from the configured endpoint URL using the existing URL hostname allowlist helper, together with the private-network grant. The allowlist is applied on each redirect hop, including environment-proxy dispatch. No new parser, guard or transport was added, and the helper's signature is unchanged for its consumers.

Evidence

Run with Node 24.22.2 and pnpm 12.15.0. No live endpoint, provider or proxy was contacted; DNS and transport are mocked.

  • The new regression (src/agents/tools/web-guarded-fetch.redirects.test.ts) calls withSelfHostedWebToolsEndpoint with the real redirect and network guards. On main it fails 2 of 5 cases: in both direct and proxy mode, a same-host hop followed by a hop to another host returns that host's response. On this branch all 5 pass, including private DNS, IPv4 and IPv6 endpoint controls.
  • A second, separately written test set through the same helper: 41 failed / 13 passed on main, 54 passed on this branch. Off-host requests stop before the second transport call; private-service and same-host controls succeed.
  • The affected consumer suites (guarded fetch, web search provider common, Brave, Firecrawl, web fetch tools): 100 tests passed.
  • Full build, test typechecking, scoped lint, formatting and the test-line budget check passed. The regression adds 57 test lines with an equal dedicated allocation.

Gap: the broad pnpm check reports 22 line-cap errors outside this change, which reproduce with identical diagnostics on an untouched main. Live provider and proxy integration were not exercised.

Real network dispatch (loopback)

The exported withSelfHostedWebToolsEndpoint helper was run from source with real DNS, real HTTP servers and the real transport. Nothing is mocked: no DNS or fetch replacement, no injected policy or dispatcher.

  • Base: b382a29a688a. Head: a2c15cc68999, this change before it was rebased onto current main; the patch is identical. Node 24.22.2.
  • Server A is the configured endpoint at localhost. Server B is a different hostname, 127.0.0.1, on another port. Both listen only on loopback inside a network namespace with no external interface.
  • A serves /control (200), /same-host → /same-host-result (302 then 200), and the chain /search → /next → B /result (two 302s). B logs every TCP connection and request.
  • Proxy mode points HTTP_PROXY/HTTPS_PROXY at a local forward proxy that supports CONNECT and logs what it forwards.
Scenario Base Head
Direct, private control 200 from A 200 from A
Direct, same-host redirect 200 from A 200 from A
Direct, redirect to other host B receives GET /result; callback gets B's response rejected after A's second hop; B receives 0 requests and 0 TCP connections; callback not called
Proxy, private control 200 from A 200 from A
Proxy, same-host redirect 200 from A 200 from A
Proxy, redirect to other host proxy opens a CONNECT tunnel to B; B receives GET /result; callback gets B's response rejected after A's second hop; no CONNECT to B; B receives 0 requests and 0 TCP connections

Head rejection message in both modes: Domain policy: Blocked hostname (not in allowlist): 127.0.0.1. Permitted hostname patterns: localhost.

Limits: loopback fixtures over plain HTTP, not a real search provider or TLS endpoint; this exercises the shared helper boundary, not a full agent turn. The latest-stable upgrade run is below.

Upgrade trace: v2026.11.4 to this head

A real Gateway was started on each version against one persisted state directory, and web_search was invoked three times through POST /tools/invoke with the real SearXNG provider. The search servers are loopback HTTP stand-ins; no model takes part. On both versions requests started only after /startupz returned 200 with status: started.

  • Release: v2026.11.4 (d843d6af39a4). Head: 621237fdf4c6. Frozen-lockfile install and full build passed on both. Node 24.22.2.
  • Persisted setting: plugins.entries.searxng.config.webSearch.baseUrl = "http://localhost:19390". The config file was byte-identical from release shutdown through head Doctor and head Gateway (SHA-256 17f338d5eed03df4f52eb58948fd83550c4795e0ce6cad276e2b60c1e392206d). No manual state edit and no downgrade override.
  • Server A is the configured endpoint, localhost:19390. Server B is a different hostname, ip6-localhost:19391.

Provider requests in arrival order, all GET:

Order Server and request v2026.11.4 Head
1 A /search?q=ordinary&format=json 200 200
2 A /search?q=same&format=json 302 to A 302 to A
3 A /same-final 200 200
4 A /search?q=cross&format=json 302 to B 302 to B
5 B /cross-final 200; B's result returned to the tool no request

Ordinary and same-host searches return results on both versions. The release follows the cross-host redirect and B receives 1 request. Head rejects ip6-localhost under the hostname policy, B receives 0 requests, and the tool returns a SearXNG provider_error payload.

Limits: this shows request behavior after a release-to-head state handoff, not a clean upgrade. openclaw doctor exited 0 on the release and 1 on head: head refused the session-entry-state migration before Gateway start and reported two shared-state inspection failures afterwards. Head's Gateway migrated state/agent schemas from 22/27 to 40/42 using its built-in generic-copy fallback (previous databases retained, conservation reported OK). This change touches only src/agents/tools/web-guarded-fetch.ts and its tests; main without it was not run as a control. The fixture is isolated, with no model configured and a restricted temporary directory, which produced the same warnings on both versions. Plain HTTP stand-in servers; no HTTPS. The agent-turn run is below. The same trace run from v2026.11.3 gave the same request results.

Agent turn through the Gateway: v2026.11.4 and this head

The same three searches, driven by full agent turns rather than direct tool calls. Each turn was sent with the documented openclaw agent --agent main --message … --json through the running Gateway, after /startupz returned 200. The agent loop made two model requests per turn: the model asked for web_search, the product ran the real SearXNG provider, and the model received the tool result and replied. The model is a deterministic loopback stand-in speaking the native Ollama protocol, not a hosted model; every model request body was captured. Same builds, setting and servers A and B as the upgrade trace, on a fresh state directory provisioned by the release.

Turn v2026.11.4: requests in order v2026.11.4: tool result shown to the model Head: requests in order Head: tool result shown to the model
ordinary A /search 200 results from A A /search 200 results from A
same-host A /search 302, A /same-final 200 results from A A /search 302, A /same-final 200 results from A
cross-host A /search 302, B /cross-final 200 results from B A /search 302, no request to B tool error, provider_error

All six turns completed with CLI exit 0 and a final reply. B received 1 request across the release turns and 0 across the head turns. On head the Gateway logged Blocked hostname (not in allowlist): ip6-localhost, and the model's reply reported the error instead of B's content.

Limits: model and search servers are loopback stand-ins; no hosted model, external search engine or HTTPS. The Doctor and state-migration observations from the upgrade trace apply unchanged to this run.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR restricts self-hosted web-tool requests and redirect hops to the configured endpoint hostname.

Example: A configured endpoint at http://localhost:19390 redirects a search to http://ip6-localhost:19391/cross-final.

  • Before: The second server receives the request and its results reach the tool.
  • After: The hostname policy rejects the redirect before contacting the second server.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair supported by real transport and shipped-entry-point traces, with explicit fixture limitations.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied real DNS, HTTP-server and forward-proxy traces exercise the changed production helper and show no connection to the off-host destination after rejection; current-head Gateway and CLI agent traces additionally exercise SearXNG with successful ordinary and same-host searches. Model and provider servers are loopback stand-ins, with no hosted-model or HTTPS coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A self-hosted search or fetch service can redirect a request to an unrelated host while retaining unrestricted private-network access.
Reason: The maintainer-authored direction accepts the compatibility tradeoff, and the repair confines an existing network grant without adding configuration or another policy owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current hostname-confinement gap with a focused change; no introduced correctness or security defect was found.

Priority: P2
Reviewed head: 621237fdf4c645e6aa14bd7bb3022995d4733108

Before merge

None.

Findings

None.

Agent review details

How this fits together

SearXNG, Brave and Firecrawl pass configured endpoint requests through a shared web-tool fetch helper, which supplies policy to the existing SSRF and redirect guard before network dispatch.

flowchart TD
  A[Configured web provider] --> B[Self hosted endpoint helper]
  B --> C[Endpoint hostname policy]
  C --> D[Guarded fetch redirect loop]
  D --> E[Direct or proxy transport]
  D --> F[Reject other hostname]
  E --> G[Provider response]
Loading

Technical review

Best possible solution:

Keep hostname confinement in the existing self-hosted fetch owner while preserving configured private endpoints and same-host redirects.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows the unrestricted private-network policy surviving redirect hops, and the supplied release/control traces demonstrate the resulting off-host request; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: derive the existing hostname policy at the shared self-hosted boundary and let the existing redirect guard enforce it for every consumer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against fd8d012d70c7.

Provenance checked

  • Self-hosted endpoint private-network policy changes intended behavior with a stated reason (1771160: Separate self-hosted private-network access from the stricter trusted-provider path.)
  • Endpoint-scoped fake-IP hostname policy keeps the original intent (fix(network): scope fake-IP SSRF policy to provider hosts #76887: Scope fake-IP allowances to provider hosts rather than carrying them to unrelated destinations.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source -3, Tests +57, Other +3. Total +57 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 5 8 -3
Tests 2 58 1 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 4 66 9 +57

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: A focused security hardening repair affects configured self-hosted web-tool endpoints.
  • merge-risk: 🚨 compatibility: Existing endpoints that redirect to another hostname will be rejected; the maintainer-authored direction explicitly accepts this change and documents configuring the destination directly.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (5 earlier review cycles)
  • reviewed 2026-11-10T20:32:29.901Z sha a2c15cc :: needs real behavior proof before merge. :: [P3] Remove model attribution and agent-workflow boilerplate
  • reviewed 2026-11-13T18:14:23.345Z sha a2c15cc :: needs maintainer review before merge. :: none
  • reviewed 2026-11-13T18:22:03.937Z sha a2c15cc :: needs maintainer review before merge. :: none
  • reviewed 2026-11-16T22:39:21.792Z sha 621237f :: needs maintainer review before merge. :: none
  • reviewed 2026-11-17T00:08:23.111Z sha 621237f :: needs maintainer review before merge. :: none

Reviewed November 16, 2026, 7:36 PM ET / November 17, 2026, 00:36 UTC (Revision 6).

@drobison00

Copy link
Copy Markdown
Contributor Author

GPT - 6.1 Sol - eng-web (engineer) via @drobison00

Updated the description: added running-product evidence on base and head under Evidence, and removed the closing process note. @clawsweeper re-review

@drobison00

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

GPT - 6.1 Sol - eng-web (engineer) via @drobison00 - Description updated: attribution line removed; running-product evidence on base and head is under Evidence.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@drobison00

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

GPT - 6.1 Sol - eng-web (engineer) via @drobison00 - Rebased onto current main; a v2026.11.3-to-head upgrade trace is now under Evidence.

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 16, 2026
@drobison00

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

GPT - 6.1 Sol - eng-web (engineer) via @drobison00 - The upgrade trace under Evidence now runs from v2026.11.4 to this head.

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@drobison00

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

GPT - 6.1 Sol - eng-web (engineer) via @drobison00 - Added agent-turn traces through the Gateway on v2026.11.4 and this head under Evidence.

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Nov 17, 2026
@drobison00
drobison00 merged commit db3a484 into openclaw:main Nov 19, 2026
149 checks passed
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…196847)

(cherry picked from commit db3a484)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 1e0f5437b92e3323c3d4c9bfeeeb065d735911a3)
(cherry picked from commit 75a18b930e9954881b7cf4c3e0df460dfc10f2b9)
tideclaw-bot added a commit that referenced this pull request Nov 24, 2026
…196847)

Baseline adaptation: Use stable guarded fetch and its existing exact-host allowlist. Keep operator-configured private endpoints usable and verify the policy passed from the self-hosted endpoint owner.

(cherry picked from commit db3a484)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit a7b18700b4883518f9d8318f91e2803a3943d334)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant