Repository navigation
fix(ollama): bypass managed proxy for loopback embeddings - #85707
Conversation
|
Codex review: needs real behavior proof before merge. Latest ClawSweeper review: 2026-05-23 19:39 UTC / May 23, 2026, 3:39 PM ET. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
PR Surface View PR surface stats
Summary Reproducibility: yes. from source, not from a live run: current main routes strict guarded Ollama embedding fetches through the env proxy when managed proxy mode is active. I did not run a live fake-proxy repro in this read-only review. PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the narrow guarded implementation only after maintainers accept the scoped Ollama local-IPC exception and private bundled-only SDK seam, and after current-head transport proof plus CI classification are in place. Do we have a high-confidence way to reproduce the issue? Yes from source, not from a live run: current main routes strict guarded Ollama embedding fetches through the env proxy when managed proxy mode is active. I did not run a live fake-proxy repro in this read-only review. Is this the best way to solve the issue? Unclear until maintainer decision: the patch is narrow and well-guarded, but the default local-IPC exception and private SDK seam are policy/API-shape choices. A safer alternative, if maintainers reject the default bypass, is an explicit opt-in or different owner-approved internal hook. Label justifications:
Security concerns:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against d2e9f91cecc7. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
5093f4e to
206242a
Compare
8a31939 to
bd9e47a
Compare
Maintainer decision note: recommended approachI want to make the remaining design decision explicit from the contributor side. This PR is our recommended approach for the Ollama part of #81249, not just a mechanical patch to get CI green. Problem analysis#80751 fixed exact-origin SSRF trust for configured local/custom provider For bundled Ollama memory embeddings, the configured loopback Viable approaches
Why this PR is the recommended approachThe current patch matches the actual ownership boundary: Ollama memory embeddings are the only path asking for this exception, and only for the exact configured loopback origin. Public, LAN/private non-loopback, public cloud, mismatched port, and redirect targets do not inherit the bypass. Operators who want stricter behavior still have the existing policy controls: That makes this smaller and safer than a general proxy bypass, while avoiding a new public config knob for the normal local-Ollama case. Addressing the review risks
Maintainer askOur recommendation is option 1: accept the scoped Ollama IPC exception and the bundled-only private seam as implemented. If maintainers prefer option 2 or 3, I can revise in that direction, but I would avoid broad |
f50710e to
15a7da3
Compare
…5707) * fix(ollama): bypass proxy for local embeddings * fix(ollama): keep managed proxy bypass loopback-only * fix(ollama): keep proxy bypass internal * fix(ollama): keep proxy bypass private * fix(ollama): harden internal proxy bypass * chore(plugin-sdk): refresh api baseline * fix(ollama): keep internal bypass out of qa aliases * test(ollama): keep ssrf runtime mock complete * fix(ollama): keep dist sdk aliases public-only * fix(ollama): keep fetch bypass out of infra runtime * fix(ollama): preserve packaged private sdk alias * test(ollama): harden private ssrf alias coverage * test(ollama): cover private ssrf resolver edges * fix(ollama): scope private sdk native aliases * test(ollama): audit blocked loopback bypasses * fix(plugins): keep staged sdk aliases public-only * test(ollama): harden proxy bypass proof * test(ollama): cover origin mismatch proxy path * test(ollama): cover ipv6 and batch bypass paths * fix lint findings in Ollama proxy tests * refactor: tighten Ollama proxy bypass * fix: widen private sdk owner registry type * test: stabilize Ollama proxy PR checks --------- Co-authored-by: Peter Steinberger <[email protected]>
…5707) * fix(ollama): bypass proxy for local embeddings * fix(ollama): keep managed proxy bypass loopback-only * fix(ollama): keep proxy bypass internal * fix(ollama): keep proxy bypass private * fix(ollama): harden internal proxy bypass * chore(plugin-sdk): refresh api baseline * fix(ollama): keep internal bypass out of qa aliases * test(ollama): keep ssrf runtime mock complete * fix(ollama): keep dist sdk aliases public-only * fix(ollama): keep fetch bypass out of infra runtime * fix(ollama): preserve packaged private sdk alias * test(ollama): harden private ssrf alias coverage * test(ollama): cover private ssrf resolver edges * fix(ollama): scope private sdk native aliases * test(ollama): audit blocked loopback bypasses * fix(plugins): keep staged sdk aliases public-only * test(ollama): harden proxy bypass proof * test(ollama): cover origin mismatch proxy path * test(ollama): cover ipv6 and batch bypass paths * fix lint findings in Ollama proxy tests * refactor: tighten Ollama proxy bypass * fix: widen private sdk owner registry type * test: stabilize Ollama proxy PR checks --------- Co-authored-by: Peter Steinberger <[email protected]>
…5707) * fix(ollama): bypass proxy for local embeddings * fix(ollama): keep managed proxy bypass loopback-only * fix(ollama): keep proxy bypass internal * fix(ollama): keep proxy bypass private * fix(ollama): harden internal proxy bypass * chore(plugin-sdk): refresh api baseline * fix(ollama): keep internal bypass out of qa aliases * test(ollama): keep ssrf runtime mock complete * fix(ollama): keep dist sdk aliases public-only * fix(ollama): keep fetch bypass out of infra runtime * fix(ollama): preserve packaged private sdk alias * test(ollama): harden private ssrf alias coverage * test(ollama): cover private ssrf resolver edges * fix(ollama): scope private sdk native aliases * test(ollama): audit blocked loopback bypasses * fix(plugins): keep staged sdk aliases public-only * test(ollama): harden proxy bypass proof * test(ollama): cover origin mismatch proxy path * test(ollama): cover ipv6 and batch bypass paths * fix lint findings in Ollama proxy tests * refactor: tighten Ollama proxy bypass * fix: widen private sdk owner registry type * test: stabilize Ollama proxy PR checks --------- Co-authored-by: Peter Steinberger <[email protected]>
Replacement for closed #85448
This PR (#85707) is the ready replacement for #85448. That PR was closed as superseded by #80751, but GitHub reports the closed PR cannot be reopened by this contributor identity. The replacement branch points at the same final reviewed code head,
5093f4eddf37ea75435973ded15e4ec5ca7f97c7; no code changed from the proofed #85448 final head.The #81249 fix set: what each PR covers
Issue #81249 has multiple managed-proxy/local-loopback paths. #80751 fixed one boundary, #83255 is aimed at another, and this PR fills the remaining Ollama memory embedding gap.
1. What #80751 already fixed
#80751 fixed the SSRF trust decision for configured
custom/localmodel providerbaseUrlvalues. Its proof exercised thebuildGuardedModelFetchOpenAI-compatible model request path (POST /v1/chat/completions) and showed that an exact configured private/loopback model-provider origin can pass SSRF validation while different ports, metadata addresses, and other private targets stay blocked.That change did not add a general
NO_PROXY/ proxy bypass mechanism. It also did not change the bundled Ollama memory embedding provider (extensions/ollama/src/embedding-provider.ts) or the managed-proxy transport decision. After #80751, strict guarded fetch can allow the exact loopback origin but still route the request throughcreateHttp1EnvHttpProxyAgentwhenever the managed proxy is active and proxy env is configured.2. What #83255 is intended to fix
#83255 is the browser/CDP path. It adds a narrow managed-proxy bypass for the exact loopback Chrome DevTools HTTP discovery and WebSocket endpoints used by the managed browser profile, for failures like
cdp=http://127.0.0.1:<port>andws://127.0.0.1:<port>/devtools/browser/...returning proxy 502/503.That PR is still open at the time this replacement PR is opened. It does not change Ollama, model-provider, or embedding-provider routing.
3. What this PR fills
PR #85707 fills the remaining #81249 gap for bundled Ollama memory embeddings. The Ollama memory embedding provider calls
/api/embedon the configured OllamabaseUrl; withproxy.enabled=true, that request can still be sent through the managed proxy. If the proxy container cannot reach the OpenClaw host's loopback service,http://127.0.0.1:11434/ local Ollama can still fail even after #80751.The fix is intentionally narrow: bundled Ollama memory embeddings may use a private internal configured-local-origin helper that can bypass the managed proxy only for the exact configured loopback origin, after DNS/policy validation, and only when
proxy.loopbackModeallows it. Public, LAN/private non-loopback, unrelated local services, different ports, metadata addresses, and redirects away from the configured origin do not get this bypass.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.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.Replacement PR opening preflight against current
origin/mainat55a0c9b1f47453b0a5b78a20cec033843c73bae4:git merge-tree --write-tree origin/main HEADproduced a clean merge tree.git diff --check origin/main...HEADpassed.Review gates completed at the exact code 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 from #85448's final reviewed head:
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 or command run 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.
Supersedes closed #85448.