Repository navigation
fix(server): OS-trust egress helper for all external fetches, bare fetch banned - #2835
Conversation
…tch banned Every bare Node fetch in the server (undici) bypasses the OS certificate store, so on enterprise machines with TLS interception any external call fails with a generic 'fetch failed' while Electron and the engine succeed (field incident class). One shared helper now routes egress: externalFetch prefers Electron net.fetch (Chromium stack, OS trust) when embedded and falls back to global fetch standalone; loopbackFetch documents engine/127.0.0.1 traffic where CA trust is irrelevant and streaming performance matters. All server call sites migrated; a guard test fails the build on new bare fetch call sites. Engine-side plugin bundles (src/opencode-plugins) are deliberately out of scope — they run inside Bun, which trusts the OS store.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
fraimz — ✅ PASSED1 passed · 0 failed · 0 skipped — run Full frame proof with validated screenshots: ✅ windows-enterprise-ca-rootcause — Windows packaged app uses OS trust and engine-attested Cloud MCP readinessInternal demo
|
fraimz — ✅ PASSED1 passed · 0 failed · 0 skipped — run Full frame proof with validated screenshots: ✅ windows-enterprise-ca-error-state — Windows enterprise CA error state: old build fabricates outage, fixed build trusts engine truthInternal demo
|
Summary
Root-cause fix #3 from the corporate-TLS field incident (follow-up to #2823, which fixed one call site). The server had ~15 external egress points on bare undici
fetch— every one of them fails behind enterprise TLS interception while Electron/engine succeed, producing the same false-negative ghost class. This PR centralizes egress and bans regressions.apps/server/src/server-fetch.ts:externalFetch(Electronnet.fetchwhen embedded → Chromium stack, OS trust store; global fetch standalone/tests) andloopbackFetch(documented alias for 127.0.0.1 / managed engine traffic, where CA trust is irrelevant and SSE/proxy streaming perf matters)externalFetch; session/SSE engine proxy, instance dispose, engine MCP register/disconnect →loopbackFetch(full file:line inventory in the commit-adjacent notes below)window.fetch(they execute in the browser, not the server)no-bare-fetch.test.tsrecursively fails on any barefetch(inapps/server/src(excluding tests,server-fetch.ts, andsrc/opencode-plugins/— plugin bundles run inside the Bun engine, which trusts the OS store, and must not import electron)Call-site inventory
externalFetch: cloud-mcp-health.ts:1074,1170 · routes/workspaces.ts:137 · skill-hub.ts:36,50,234 · claude-plugin-bundle.ts:101,113 · extensions/openai-image-generation.ts:116 · extensions/google-workspace.ts:512,1116,1254 · server.ts:475,519,3040
loopbackFetch: server.ts:1038 (async session command proxy) · server.ts:1047 (hot OpenCode proxy/SSE) · server.ts:3198 (instance dispose) · server.ts:3367 (runtime MCP registration) · server.ts:4040 (MCP disconnect)
Validation
pnpm --filter openwork-server exec bun test src/no-bare-fetch.test.ts— 1 pass / 0 failpnpm --filter openwork-server test— 451 pass / 0 fail (existing tests stubglobalThis.fetch;externalFetchfalls back to it outside Electron, so stubs keep working — verified by the green suite)pnpm --filter openwork-server typecheck— cleanrg --pcre2 '(?<![.\\w])fetch\\s*\\('over migrated scope — no hits outside exclusionsNot run: live enterprise-TLS e2e (Electron-embedded
net.fetchpath behind a MITM CA) — that's thedaytona-windows-certsandbox; recommended as the release-gate follow-up for this class.Note: touches
cloud-mcp-health.tsalongside the parallel engine-attested-health PR (different regions; second-to-merge takes a trivial rebase).