Repository navigation
fix(secrets): Node fetch in exec can't reach local HTTP servers with the secret egress proxy on - #186765
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
✅ Maintainer security changes approvedA maintainer approved this revision with an explicit security approval comment.
A later push requires a fresh approval comment for an external contributor's PR. |
|
Codex review: blocked before merge. What this changesThis PR supports permitted loopback HTTP inside CONNECT tunnels while preserving destination binding, secret refusal, and process revocation. Example: Node 24.22.1 fetches http://127.0.0.1:11434/api/version through Gateway-hosted exec with secret egress enabled.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR fixes a current-main transport bug, with no actionable introduced defect found; current-head maintainer security approval remains enforced. Priority: P2 Before merge
FindingsNone. Agent review detailsHow this fits togetherThe Gateway-owned secret-egress worker receives authenticated subprocess proxy requests, checks process and destination authority, and forwards permitted HTTP or HTTPS traffic without exposing protected credentials to the subprocess. flowchart TD
A[Gateway exec subprocess] --> B[Authenticated proxy]
B --> C[CONNECT destination policy]
C --> D[Loopback protocol detection]
D --> E[HTTP or TLS request parser]
E --> F[Shared forwarding and secret policy]
F --> G[Permitted upstream service]
Technical reviewBest possible solution: Retain the proxy-owned CONNECT repair and merge after current-head security approval and required checks succeed. Do we have a high-confidence way to reproduce the issue? The credential-free reproduction in #181524 and current-main TLS-only CONNECT dispatch establish the failure path; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs protocol dispatch at the existing proxy boundary, reuses forwarding policy, and preserves the earlier decision against a loopback bypass. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 97b24c9d15d5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +77, Tests -1, Docs 0. Total +76 across 7 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 5, 2026, 2:59 AM ET / 07:59 UTC (Revision 4). |
|
Fixed the baseline ratchets (e136708) and added proof to the body. @clawsweeper re-review @steipete @joshavant PTAL when you get a chance. Thank you! |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@vincentkoc @obviyus PTAL when you get a chance. It needs |
Keep Node 24 fetch working through the secret egress proxy without allowing inner request targets to escape either plaintext or TLS tunnel origins. Bound protocol detection and check current process authority before handoff. Exercise stock Node fetch and raw tunnel requests, including origin changes, plaintext sentinel refusal, idle peers and revocation during protocol sniffing. Consolidate existing proxy fixtures without increasing the test-line budget. Co-authored-by: Eric Curtin <[email protected]>
Distinguish an empty protocol read from plaintext so ended sockets never enter the tunnel HTTP parser. Preserve origin pinning and grant checks. Extend the raw-socket reset regression with authenticated CONNECT/200/EOF and clarify upstream proxy routing for literal loopback HTTP destinations. Keep test growth nonpositive by simplifying server cleanup fixtures.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
/allow-security-sensitive-change |
|
Merged via squash.
|
#186765 moved the only external caller behind createRequestServer, so the unused export fails the deadcode scan. Keep the function and drop the export.
…the secret egress proxy on (openclaw#186765) * fix(secrets): Node fetch to local HTTP fails with the egress proxy * test(secrets): fold CONNECT tunnel tests into proxy-server.test, drop type assertion * fix(secrets): pin and bound loopback CONNECT tunnels Keep Node 24 fetch working through the secret egress proxy without allowing inner request targets to escape either plaintext or TLS tunnel origins. Bound protocol detection and check current process authority before handoff. Exercise stock Node fetch and raw tunnel requests, including origin changes, plaintext sentinel refusal, idle peers and revocation during protocol sniffing. Consolidate existing proxy fixtures without increasing the test-line budget. Co-authored-by: Eric Curtin <[email protected]> * fix(secrets): release CONNECT peers that end before sending bytes Distinguish an empty protocol read from plaintext so ended sockets never enter the tunnel HTTP parser. Preserve origin pinning and grant checks. Extend the raw-socket reset regression with authenticated CONNECT/200/EOF and clarify upstream proxy routing for literal loopback HTTP destinations. Keep test growth nonpositive by simplifying server cleanup fixtures. * test(secrets): observe CONNECT peers across Node and Bun --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Eric Curtin <[email protected]>
openclaw#186765 moved the only external caller behind createRequestServer, so the unused export fails the deadcode scan. Keep the function and drop the export.
Adapt source 6769a69 (openclaw#186765). Preserve existing proxy authority, original controls and TLS resume companion; restore source tunnel controls and isolate sibling fixture proxy environment. Exact test allocation: 380 LF. Node24-specific fetch remains unqualified; current-parent proof follows. (cherry picked from commit 6769a69) Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit c9046c0b902ca80ae264f2dec1d52453892ea2dc)
Closes #181524
What Problem This Solves
Fixes: stock Node 24
fetchfrom Gateway-hosted exec fails withUND_ERR_SOCKETwhen secret egress is enabled and the destination is a permitted loopback HTTP service. The repair also closes a CONNECT peer that ends without sending protocol bytes, instead of retaining its socket until the process grant is revoked.User Impact
Exec can reach local Ollama, llama.cpp and similar HTTP servers through the authenticated proxy. Traffic policy, process revocation, audit and the prohibition on plaintext secret substitution remain enforced. No proxy bypass or new configuration is required. Thanks @ericcurtin for the original diagnosis and CONNECT support; their commits are preserved.
Why This Change Was Made
Node 24.22.1 (Undici 7.30.1) tunnels ordinary HTTP through CONNECT. Node 26.12.1 (Undici 8.12.2) uses direct proxy requests, which already worked. The proxy now classifies literal-loopback tunnel bytes and hands plaintext or TLS to the existing forwarding owner.
Both plaintext and TLS inner URLs are pinned to the CONNECT scheme, host and port before forwarding or secret substitution. Absolute and network-path origin changes are refused, and a forged
Hostcannot select the destination. Plaintext sentinels and WebSocket upgrades remain refused. The sniff has a 30-second deadline, removes its listeners/timer, and rechecks current grant authority immediately before either handoff. An empty read is a distinct EOF result and destroys the peer; it is never handed to the HTTP parser. Non-loopback and configured bypass policies remain unchanged.Upstream routing still honors Gateway
HTTP_PROXY/HTTPS_PROXYandNO_PROXY. The docs now explicitly say that a loopback HTTP address routed through an upstream proxy refers to that proxy's loopback interface. No secrets are substituted onto that cleartext route.This source remains subject to the repository's security-sensitive review policy. Maintainer security approval is still required.
Evidence
Checksum-verified nodejs.org runtimes on macOS arm64, stock global fetch, real proxy process grants, and shared Ollama:
UND_ERR_SOCKET(105 / 10 ms)Diagnostics confirm Node 24 uses CONNECT and both runtimes connect to the injected proxy. A prior isolated Gateway run on port 20453 used a real
qwen2.5:7bagent turn to invoke stock Node 24.22.1 throughexec: main failed/api/versionand/api/embed; the repaired build returned 200 and a finite 768-dimensionalnomic-embed-textvector. That Gateway proof is reused: the EOF follow-up changes only empty-peer handling, and the successful plaintext/TLS handoffs are unchanged. The final-source proxy probes above recheck stock fetch after that follow-up. Shared Ollama was neither restarted nor unloaded.The EOF regression uses a raw socket: authenticated
CONNECT 127.0.0.1:9, await 200,end(), then observe the proxy peer's end/close event and assert it was destroyed. It failed on commit3bed05ce26cf14feb3ca5f3a7e0a8c8eb2a978f4withexpected false to be true; it contains no timers, sleeps or polling. It shares the existing reset/recovery test. Earlier origin/deadline/authority regressions also failed against the original contributor implementation before passing with the repair.Validation: all 96 proxy, lifecycle and WebSocket tests passed on Node 24.22.1 (132.63s wrapper wall time; 94.97s Vitest) and Node 26.12.1 (94.18s wrapper; 84.58s Vitest). Summed case times stayed under five seconds per file. The final EOF regression failed against the prior production code in 68.49s, with the intended destroyed=false assertion, and the exact final production bytes were restored. All eight EOF/Basic-header cases passed in the final targeted rerun (66.31s wrapper wall time). Core and test types, scoped lint, format, baseline ratchets and the line-cap check pass. A one-line test-file cap overflow was corrected without removing coverage. Codex branch-mode autoreview of
15bec5ab81c2e1f4a10060d6551e37b8ec225264..0d16d58c5c85ed71217bb4a0eeceff08db093ea9is scoped-clean at P0–P2 (0.88), with no accepted/actionable findings. The approved review scope excludes explicit source-context files; that scope limitation is retained.The first CI run found five Bun-only test setup failures: Bun delivers HTTP connections without calling the JavaScript
net.Server.emitmethod observed by the fixture. The fixture now captures real peer sockets through their public listener registrations, preserving the EOF/deadline/revocation assertions. The same five cases failed locally before the correction and passed afterward on the pinned Bun fork (15.30s), Node 24.22.1 (46.28s), and Node 26.12.1 (62.67s). Production code is unchanged by this test-only follow-up. Final-head CI passed all 33 selected jobs. ClawSweeper reviewed this final head with no actionable findings and 5/6 patch/proof scores; its only merge hold is maintainer security approval.Production LOC: +108/-31 (net +77); test LOC: +472/-473 (net -1). The production growth implements protocol classification, origin pinning and bounded authority-safe handoff. The EOF follow-up adds one production line net; test cleanup uses standard promisified server closes to keep the complete regression change within the existing test-line budget. No baselines or ceilings were raised. The contributor branch incorporates main via a merge, without rebasing or replacing their commits.
Limitations and follow-up: a client that starts an HTTP header and then stalls can still retain its grant's socket until revocation, for plaintext and decrypted TLS. Node's header-timeout sweep starts on
listening, while these per-tunnel servers receive sockets without listening. Simply assigningheadersTimeoutdoes not start that sweep, and an inactivity timeout would also change active request/upgrade semantics; that needs a separate lifecycle fix.GET //v1/modelsis parsed as a network-path URL and returns 400 in both tunnel modes; the TLS refusal is unchanged by this EOF follow-up. Clients should send/v1/models. Live proof covers macOS arm64, not Linux or Windows. No release or deployment is included.