aft icon indicating copy to clipboard operation
aft copied to clipboard

aft-bridge: drop unused `undici` dependency (leftover from the Rust URL-fetch migration)

Open trim21 opened this issue 1 month ago • 0 comments

@cortexkit/aft-bridge declares undici as a runtime dependency but nothing in the package imports it any more. It is a leftover from the "Migrate URL fetching to Rust" work, and it makes every downstream lockfile carry a vulnerable copy of undici (GHSA-4qv8-2p9j-2685 plus 7 other advisories).

Where it is declared

  • packages/aft-bridge/package.json:34 — "undici": "^7.25.0" under dependencies
  • packages/opencode-plugin/package.json:48 — same, under dependencies
  • packages/pi-plugin/package.json does not declare it

History — it was used, then the code was deleted and the dependency was not

  • 4de4f288c (fix(opencode-plugin): pin URL fetch DNS resolution) added undici to the opencode-plugin for a DNS-pinned fetch in packages/opencode-plugin/src/shared/url-fetch.ts.
  • b090b8875 (refactor: extract @cortexkit/aft-bridge shared package) moved that file into packages/aft-bridge/src/url-fetch.ts, together with the dependency.
  • 15f1cd0ae (fix(aft-bridge): pin undici@7 to avoid Bun load-time crash) narrowed ^8.2.0 to ^7.25.0, because undici@8 calls webidl.util.markAsUncloneable at module load time, which crashes Bun (the OpenCode TUI) with "__require is not a function".
  • 1a1a43463 (Migrate URL fetching to Rust, 2026-05-25) deleted packages/aft-bridge/src/url-fetch.ts, its unit test and the re-export from src/index.ts — but left undici in both package.json files.

So undici has been dead since 1a1a43463, and the ^7 range only exists as a workaround for a Bun load-time crash in code that no longer exists.

Verification on the current tree

  • rg -n undici packages/aft-bridge/src packages/aft-bridge/dist matches nothing outside package.json; neither ProxyAgent nor setGlobalDispatcher appears anywhere in the package.
  • packages/opencode-plugin/src has no undici import either, and src/shared/url-fetch.ts no longer exists.
  • The remaining network calls use the global fetch (packages/aft-bridge/src/downloader.ts:243, packages/aft-bridge/src/onnx-runtime.ts:804), i.e. Node's built-in fetch, not the npm package.
  • @cortexkit/subc-client has no runtime dependencies at all.
  • scripts/windows-vm/run-guest.ps1:164 still documents "aft-bridge is plain tsc and imports undici at runtime", which has been stale since 1a1a43463.

Impact

^7.25.0 resolves to 7.29.1 in a fresh install, which is affected by (fix is >= 7.30.1):

  • GHSA-4qv8-2p9j-2685 — DoS via unbounded memory in the EventSource parser
  • GHSA-f72v-6w45-q472 — Subresource Integrity bypass via non-lowercase algorithm tokens
  • GHSA-xjj6-f33q-929c — DoS via unhandled error on excessive content-encodings
  • GHSA-4w7w-5xrc-9h26 — cache poisoning / cross-user disclosure via cross-origin redirects
  • GHSA-2m5v-pch6-74hx — TLS certificate validation bypass via dropped tls options in Agent
  • GHSA-qrxm-fqhp-jwvm — DoS via TLS 1.2 certificate-changing renegotiation
  • GHSA-9fm3-97px-rjf6 — WebSocket client DoS via unbounded automatic PONG buffering
  • GHSA-55wc-3pg8-jfw6 — DoS via unhandled exception in the decompress interceptor

Downstream consumers have to add pnpm.overrides / resolutions pins, or live with permanent Dependabot alerts for a package that is never loaded.

Suggested fix

Remove undici from packages/aft-bridge/package.json and packages/opencode-plugin/package.json, and update the stale comment in scripts/windows-vm/run-guest.ps1. If a DNS-pinned fetch comes back later, the dependency should be re-added with a current version — the ^7 pin should not be carried over, since undici@8's Bun incompatibility was specific to the removed code path.

trim21 avatar Nov 03 '26 20:11 trim21