From fa3da7b031a25439e79613799b373947423ff975 Mon Sep 17 00:00:00 2001 From: ci-check Date: Tue, 27 Oct 2026 00:37:59 +0800 Subject: [PATCH] fix(security): bump zod 4.1.8 -> 4.6.7 to clear GHSA-mrhx-c7xc-m3w5 (#4820) - direct zod to the latest patched release (patched line starts at 4.6.6); pin stays exact per KDD #1 - record the jimp nested-zod@3.x audit finding as a source-level false positive (TECHNICAL-NOTES.md) - update the KDD #1 line and the opencode-native-v1 test comment to the new version --- AGENTS.md | 2 +- TECHNICAL-NOTES.md | 9 +++++++++ package-lock.json | 8 ++++---- package.json | 2 +- tests/opencode-native-v1.test.ts | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a7d63704e0..b906a98586 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -34,7 +34,7 @@ The full file-by-file map lives in [reference/architecture.md](reference/archite ### Key Design Decisions -1. **The in-repo kernel is bundled inline** — `kernel/` (the acp-kernel source, consumed as a `file:` devDependency, #2092) is NOT listed in tsup `external`, so `dist/index.js` is self-contained. Exception: `zod` (exact `4.1.8`, matching the opencode host's own zod so V1 plugin-tool shapes interoperate) is a real dependency and stays external — only `dist/agent/opencode-native.js` imports it (lazily, at plugin-tool registration); `dist/index.js` and every other entry remain zod-free. When zod cannot be resolved at runtime the V1 plugin degrades to plain proxy mode instead of failing. Same for `pi-subagents/` (the billion-context-pi-subagents source, #2384): consumed via a `file:` devDependency and inlined into the pi-lane entries; its own build inlines the `typebox` peer, so those bundles stay self-contained too. +1. **The in-repo kernel is bundled inline** — `kernel/` (the acp-kernel source, consumed as a `file:` devDependency, #2092) is NOT listed in tsup `external`, so `dist/index.js` is self-contained. Exception: `zod` (exact `4.6.7`, matching the opencode host's own zod so V1 plugin-tool shapes interoperate; bumped from `4.1.8` to clear GHSA-mrhx-c7xc-m3w5, #4820) is a real dependency and stays external — only `dist/agent/opencode-native.js` imports it (lazily, at plugin-tool registration); `dist/index.js` and every other entry remain zod-free. When zod cannot be resolved at runtime the V1 plugin degrades to plain proxy mode instead of failing. Same for `pi-subagents/` (the billion-context-pi-subagents source, #2384): consumed via a `file:` devDependency and inlined into the pi-lane entries; its own build inlines the `typebox` peer, so those bundles stay self-contained too. 2. **Tags use XML format** — messages carry ACP tags like `m00001` (an opening element with `tokens=`/`type=` attributes wrapping a ref id, closed by its end element). In **source files** these angle brackets MUST be written as hex escapes (`\x3c`, `\x3e`) to avoid tooling that strips well-formed tags. 3. **Auto-update**: checks npm registry every 3 min by default (`CHECK_INTERVAL_MS = 3*60*1000`, overridable via `update.checkIntervalMs` / `BILI_UPDATE_CHECK_INTERVAL_MS`, #2030); first check per process ignores throttle. In plugin mode the injected code lives in the HOST process — new code only takes effect after a host restart, and if the injection breaks at runtime, model traffic goes direct (uncompressed) until the host is restarted; since #3581 that state is visible via the panel banner and `/__bili/status` `attribution` field (README Self-update section). 4. **Tee logger**: all proxy logs go through `src/logger.ts` (file + stderr). Do NOT use `console.error` in server-side modules — use `loggerLog()`. diff --git a/TECHNICAL-NOTES.md b/TECHNICAL-NOTES.md index 202d9c5aa5..52d431742c 100644 --- a/TECHNICAL-NOTES.md +++ b/TECHNICAL-NOTES.md @@ -527,3 +527,12 @@ Design (`src/uncovered.ts`, host-side only, no kernel change): Behavior change (disclosed): old = unconditional "already at its minimum" on offer exhaustion; new = that claim only when the global audit verifies it AND the uncovered mass clears the 10K receipt floor — below the floor the receipt is byte-identical to master (so `tests/compress-success-tail.test.ts` stays at master bytes, zero diff), and its #2404/#1387 sub-floor residue fixtures now double as the floor's pins. Sub-gate residue became visible in acp_status (previously invisible on every surface). No config/env surface added; nudge prompt text untouched (kernel-owned). Known limitation left as a separate observation: the receipt's remaining-calc removes a WHOLE offered batch when any submitted span overlaps it, so a partially-folded merged batch can under-report rather than over-report. Tests: `tests/issue4331-uncovered-history.test.ts` (hole session → honest verdict + named span; drained session → verbatim contract string; sub-floor silence; tier precedence; **tier-2 distillation coverage pin** — three T1s distilled into one T2 parent via the real host path must not leak child spans into the audit; both acp_status directions; formatter caps) + `tests/compress-success-tail.test.ts` UNCHANGED from master (its < 10K-residue fixtures pin the floor), `tests/issue2029-status-baseline-provenance.test.ts` (every status-reader kernel call feeds the provenance baseline), `tests/issue847-compress-failure-guards.test.ts` (sub-gate residue visible in the diagnostic, still never offered). + +## Dependency audit — zod advisory GHSA-mrhx-c7xc-m3w5 and the jimp nested-zod false positive (#4820) + +A fresh-install `npm audit` reports one high-severity advisory, GHSA-mrhx-c7xc-m3w5 (CVE-2023-54404, CVSS 7.5 High, **availability/DoS only** — no confidentiality or integrity impact), against two different chains that must be handled differently: + +- **Direct `zod`** (`package.json` `dependencies.zod`, exact pin per KDD #1). Genuinely affected: the vulnerable code is `$ZodArray.handleArrayResult` in `v4/core/schemas.js`, which accumulates every per-element validation issue with no cap or early termination when validating an oversized array against an unconstrained array schema. Bumped `4.1.8 → 4.6.7` (patched line starts at 4.6.6, which adds an `abortEarly`-gated early break plus a `capSize` registration that 4.1.8 lacks). The pin stays EXACT (not a range) so npm can dedupe to one shared instance with the opencode host — the KDD #1 interop guarantee — and is covered by `tests/opencode-native-v1.test.ts`. In our tree this copy is consumed only by `src/agent/opencode-native.ts` (OpenCode V1 plugin tools, lazy opaque import); it is not loaded in the Pi/proxy lanes. +- **Jimp's nested `zod@3.x`** (`optionalDependencies.jimp`; each `@jimp/*` declares `zod ^3.23.8`, so npm nests a 3.x copy under every `node_modules/@jimp/*/node_modules/zod`). This is a **false positive for how we use jimp**, established at source level rather than assumed from the semver range: the vulnerable function exists only in zod's v4 implementation (`v4/core/schemas.js`) and never in v3; `import "zod"` in a 3.25.x install resolves to the v3 core; and `@jimp/*` import plain `"zod"` (never `zod/v4`). So the bug is unreachable through jimp. We therefore do **NOT** force-override jimp's zod 3→4 (a cross-major override with no patched 3.x to converge onto, risking jimp's own validation semantics); we track upstream instead. Reachability limits stay explicit: jimp is optional and lazy-loaded (`src/image-rescale.ts`), degrading to pass-through when absent, reachable only during image processing. Boundary: the bundled v4 preview *inside* a 3.25.x tarball is itself pre-fix — if a future `@jimp` ever imports `zod/v4`, re-evaluate this conclusion. + +A hard CI/runtime audit gate is deliberately deferred: it would stay red because of the jimp chain unless we add an exception, and any exception must be narrowly scoped, explained, and revisitable — never a blanket suppression. Revisit once the direct-zod bump has landed and upstream jimp is tracked. diff --git a/package-lock.json b/package-lock.json index 380212c96e..8d4901bae3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "mysql2": "^3.15.3", - "zod": "4.1.8" + "zod": "4.6.7" }, "bin": { "bili": "dist/index.js", @@ -9273,9 +9273,9 @@ } }, "node_modules/zod": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.8.tgz", - "integrity": "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/package.json b/package.json index ea30cea0b4..8619cd88fc 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ }, "dependencies": { "mysql2": "^3.15.3", - "zod": "4.1.8" + "zod": "4.6.7" }, "optionalDependencies": { "jimp": "1.6.1" diff --git a/tests/opencode-native-v1.test.ts b/tests/opencode-native-v1.test.ts index 8af03f87d4..cadc8bce4c 100644 --- a/tests/opencode-native-v1.test.ts +++ b/tests/opencode-native-v1.test.ts @@ -14,7 +14,7 @@ import { import { rmrf } from "./tmp-rm.ts"; // Minimal structural stand-in for the host's zod module: only the builders -// jsonSchemaToZodShape touches. Real zod (4.1.8) is exercised implicitly by +// jsonSchemaToZodShape touches. Real zod (4.6.7) is exercised implicitly by // the shape assertions below via the actual import. const fakeZ = { any: () => ({ __fake: "any" }), @@ -59,7 +59,7 @@ describe("jsonSchemaToZodShape", () => { it("produces fields the real host zod accepts in z.object()", async () => { // The v1 registry wraps our shape with the HOST's zod: simulate with - // the real zod dependency (4.1.8) to prove cross-instance interop. + // the real zod dependency (4.6.7) to prove cross-instance interop. const real = await import("zod"); const shape = jsonSchemaToZodShape( { type: "object", properties: { range: { type: "string" }, limit: { type: "number" } } },