Repository navigation
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open. The PR targets a real source-reproducible Ollama embeddings/proxy failure, but it intentionally adds a guarded direct path around the managed proxy and the supplied real-behavior proof is stale for the live head and packaging changes. Canonical path: Close this PR as superseded by #80751. So I’m closing this here and keeping the remaining discussion on #80751. Review detailsBest possible solution: Close this PR as superseded by #80751. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main routes Ollama memory embeddings through strict guarded fetch, and strict guarded fetch uses EnvHttpProxyAgent whenever managed proxy mode is active; the linked user report supplies matching proxy 503 symptoms. Is this the best way to solve the issue? Unclear until maintainer policy review. The implementation is narrow and well-guarded, but it deliberately creates an Ollama-specific loopback IPC exception to managed proxy routing. Security review: Security review needs attention: Needs attention because the diff intentionally adds a guarded direct transport path around the managed forward proxy for loopback Ollama embeddings.
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 463929d794a2. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
b2afeda to
0aa6bc3
Compare
d98178c to
64264c4
Compare
|
ClawSweeper applied the proposed close for this PR.
|
|
Follow-up after the ClawSweeper review:
Operational note: this token can update and mark the PR ready, and the draft state is now cleared, but GitHub reports |
|
Replacement PR opened as #85707 because this closed PR could not be reopened by this contributor identity. #85707 uses the same final reviewed/proofed code head, |
Problem
When
proxy.enabled=true, OpenClaw routes strict HTTP fetches through the managed forward proxy. That is the right default for ordinary egress, but it breaks the bundled Ollama memory embedding provider when the configured OllamabaseUrlpoints at a host-local loopback service such ashttp://127.0.0.1:11434: a remote or policy-strict proxy cannot reach the OpenClaw host's loopback service.PR #80751 made configured local provider origins trusted for SSRF policy purposes, but it did not change managed-proxy routing. PR #83255 addresses a separate browser/CDP loopback path. This PR covers the remaining Ollama memory embedding path.
Why this is not superseded by #80751
#80751 and this PR address adjacent but different boundaries:
custom/localmodel provider origins. Its proof exercised thebuildGuardedModelFetchOpenAI-compatible model request path (POST /v1/chat/completions) and verified that exact configured private/loopback origins pass SSRF checks while other private/metadata origins stay blocked.extensions/ollama/src/embedding-provider.ts) and did not add a managed-proxy direct transport path. After fix(agents): scope custom provider baseUrl SSRF trust by origin #80751, the Ollama memory embedding provider still called publicfetchWithSsrFGuardfor/api/embed.createHttp1EnvHttpProxyAgentwhenever the managed proxy is active and proxy env is configured. Exact-origin SSRF trust can make the loopback target allowed, but it does not make that request reachable when the managed proxy cannot reach the OpenClaw host's loopback service.proxy.loopbackModeallows it.The exact-head proof demonstrates the distinction: with
OPENCLAW_PROXY_ACTIVE=1and a fake managed proxy configured, default loopback mode reached fake Ollama directly withproxyHits=0;proxy.loopbackMode=proxysent the same request to the fake proxy withollamaHits=0; and a redirect to another loopback origin was blocked before reaching the redirect target.Change and value
This PR lets the bundled Ollama memory embedding provider mark its exact configured loopback
baseUrlas eligible for a guarded managed-proxy direct path. When the managed proxy is active, guarded fetch still resolves and validates the destination first, then uses a pinned direct dispatcher only when the request origin exactly matches the configured provider origin, the configured origin is loopback, all resolved target addresses are loopback, andproxy.loopbackModeallows it.The practical effect is that host-local Ollama memory embeddings can work with
proxy.enabled=truewithout creating a general local-network bypass. Public, LAN/private, and otherwise non-loopback Ollama origins stay on the managed proxy path.Who is affected, and who is not
Affected:
baseUrlwhile the managed proxy is active.proxy.loopbackModeto keep explicit control over loopback behavior.Not affected:
Implementation
configured-local-originmanaged-proxy bypass marker for core/bundled-provider use.openclaw/plugin-sdk/ssrf-runtimeoption surface; publicfetchWithSsrFGuardstrips forged markers before delegating.openclaw/plugin-sdk/ssrf-runtime-internal, which is private, local-only, not package-exported, and scoped by the plugin SDK alias resolver to the bundled Ollama plugin source/dist paths.ssrf-runtime-internalartifact.proxy.loopbackModeallows it.proxy.loopbackMode: "proxy"by leaving loopback traffic on the proxy path.proxy.loopbackMode: "block"by rejecting loopback provider traffic before opening a connection, including bracketed IPv6 loopback URLs.Security and maintainer decision
This intentionally treats an exact configured loopback Ollama embedding origin as operator-trusted local IPC for the bundled embedding provider. That matches the local-provider direction from #80751, but it is still a managed-proxy policy exception: under the default loopback mode, exact configured loopback Ollama embedding traffic can bypass the operator-managed forward proxy.
Maintainers should explicitly accept that policy exception. Operators who do not want this behavior can keep loopback traffic on the proxy path with
proxy.loopbackMode: "proxy", or block configured local-provider loopback traffic withproxy.loopbackMode: "block".The bypass is not a new public plugin SDK contract.
Out of scope
Verification
Exact code head under review:
5093f4eddf37ea75435973ded15e4ec5ca7f97c7.Review gates completed at that head:
--printmulti-lane review with the full current diff embedded: security/public-surface, package/runtime, and proof/tests lanes had no blocking findings after triage.origin/main: no discrete actionable regressions found.Focused exact-head gates passed:
node --check scripts/stage-bundled-plugin-runtime.mjsgit diff --check origin/main...HEADsrc/plugins/stage-bundled-plugin-runtime.test.ts(14passed)src/infra/net/fetch-guard.ssrf.test.ts(79passed)extensions/ollama/src/embedding-provider.test.ts(21passed)src/plugins/plugin-sdk-native-resolver.test.ts(5passed)src/plugins/sdk-alias.test.ts -t "aliases the Ollama SSRF internal helper only for the bundled Ollama plugin"(1passed /54skipped)src/plugins/loader.test.ts -t "private local-only plugin-sdk artifacts out"(2passed /134skipped)plugin-sdk-package-contract-guardrails.test.ts -t "configured local-origin fetch helpers"(2passed /18skipped)Final remote validation and full-suite classification:
us-east1-c,e2-standard-8, leasecbx_d95a340b2c96/blue-prawn.5093f4eddf37ea75435973ded15e4ec5ca7f97c7.9ff1a4371f6867825022c10688395cbc0e3c6d3e.origin/mainadvanced to0b2ab6c...during the run, so the classifier kept the launch-time pinned main for an apples-to-apples comparison.Remote focused gates passed on the PR head:
pr-install rc=0pr-diff-check rc=0pr-sdk-subpath rc=0pr-sdk-api rc=0pr-sdk-surface rc=0pr-sdk-alias-test rc=0(55passed)pr-plugin-contract-test rc=0(42passed)pr-bundled-loader-alias-test rc=0(4passed /132skipped)pr-tsgo-prod rc=0pr-fetch-guard-test rc=0(79passed)pr-ollama-embedding-test rc=0(21passed)Full-suite classification from the same remote environment:
pnpm test: red,13failed files parsed.pnpm test: red,14failed files parsed.0.1(src/pairing/pairing-store.test.ts).Inherited PR red paths, all present on pinned main:
src/agents/agent-command.live-model-switch.test.tssrc/agents/bash-tools.exec-approval-followup.test.tssrc/agents/pi-embedded-runner/compact.hooks.test.tssrc/agents/pi-embedded-runner/model.forward-compat.errors-and-overrides.test.tssrc/agents/subagent-announce-delivery.test.tssrc/agents/subagent-registry.announce-loop-guard.test.tssrc/commands/models/list.list-command.forward-compat.test.tssrc/gateway/call.test.tssrc/gateway/client.watchdog.test.tssrc/gateway/handshake-timeouts.test.tssrc/gateway/server-runtime-config.test.tssrc/gateway/server-startup-config.secrets.test.tssrc/gateway/server.preauth-hardening.test.tsReal behavior proof
Behavior or issue addressed: Ollama memory embeddings configured to a host-local loopback
baseUrlshould still work whenOPENCLAW_PROXY_ACTIVE=1andHTTP(S)_PROXYpoints at a managed proxy that cannot reach host loopback. The same path should keepproxy.loopbackMode=proxyon the proxy path and should not trust redirects away from the configured origin.Real environment tested: Exact PR head
5093f4eddf37ea75435973ded15e4ec5ca7f97c7in the OpenClaw source worktree, Node v26.1.0. The proof starts a fake Ollama-compatible/api/embedservice on127.0.0.1:<random>and a fake managed proxy on127.0.0.1:<random>that returns 503 for ordinary and CONNECT requests. It setsOPENCLAW_PROXY_ACTIVE=1, pointsHTTP_PROXY/HTTPS_PROXYat the fake proxy, and clears proxy bypass environment for the request.Exact steps after this patch: A temporary proof harness imported
extensions/ollama/src/embedding-provider.ts, created the real Ollama embedding provider withremote.baseUrlset to the fake loopback service, and executed three requests: default loopback mode,proxy.loopbackMode=proxy, and a cross-origin loopback redirect.Evidence after fix:
Observed result after fix: In default loopback mode, the real Ollama embedding provider code reached the fake host-local Ollama service directly, returned the normalized vector
[0.6, 0.8], and did not hit the fake proxy. Withproxy.loopbackMode=proxy, the same request hit and failed through the fake proxy without reaching fake Ollama. A redirect from the configured origin to a different loopback port was blocked by the existing SSRF guard before reaching the redirect target or proxy.What was not tested: A real Ollama daemon/local model was not exercised. The proof covers the provider transport and response-handling path with an Ollama-compatible fake
/api/embedendpoint and fake managed proxy, not actual local model execution. Fullpnpm testremains red in the remote environment, but the exact-head comparison classified the red paths as inherited from pinnedorigin/main, with no PR-only failed files.Related #81249.