Repository navigation
Description
cold-store-reaper(worker): zstd decompression is unbounded — a small frame expands without limit before the sha256 check, and the manifest's expected plaintext size is selected but never used
Evidence (verified this run, laptop @ 9123103 == origin/main)
The rehydrator Worker (pkgs/cold-store-reaper/worker/) verifies an object's sha256 before serving it, but the verification happens after the frame has been decompressed whole, with no size bound at any point:
src/decoder.js:12—decompressFrame(frameBytes)is exactlyreturn decompress(frameBytes)(fzstd): the whole expanded output is allocated in memory, whatever size the frame declares/produces.src/index.js:196—BundleFlight.rehydratecallsdecompressFrame(frame)on the Drive-pulled frame; the sha256 comparison (src/index.js:200-203) runs only on the fully expandedplain.src/index.js:169—rehydratedestructures only{ drive_file_id, offset, frame_length, sha256, bundle_id }from the job. The entry-point SQL (src/index.js:229) already selectso.size AS size— the object's expected plaintext size — and the row is posted whole to the Durable Object, so the one number that could bound the expansion is in the job and is never read.
Probe (laptop, ~/git/fleet/probe-coldstore-bomb/, fzstd from the worker's own package.json/package-lock.json, zstd -19 CLI frame):
- Frame of 64 MiB of zero bytes: 2,077 compressed bytes → 67,108,864 decompressed bytes, RSS +70.1 MiB, via the same
decompress()calldecompressFramemakes. The expansion ratio scales with the frame, not withframe_length: a few-KiB frame can declare/expand past the Worker's 128 MB memory limit, so a corrupt or hostile bundle member kills the Worker/DO with an out-of-memory crash instead of producing the designed clean 502 ("refusing to return unverified bytes"). - Control intent already in the tree: the Range-ignored download path was bounded for exactly this reason (perf(cold-store-reaper): bound memory when Drive ignores Range requests #6182 —
readStreamedFrame,src/index.js, "peak memory tracks frame_length rather than the bundle size"). Decompression is the remaining stage where peak memory tracks neither the frame size nor the expected object size.
Why it matters
The Worker's contract is fail-closed with a 502 on any Drive, decompression, or hash failure. An unbounded decompress breaks that contract in the worst direction: instead of a 502, the isolate dies — for the single-flight Durable Object, taking down every joined concurrent fetch for that bundle with it. It also makes the service fragile for legitimate restorations: any object whose plaintext is large relative to isolate memory cannot be served (or refused cleanly) because the known expected size is ignored. The data needed to fix it is already flowing through the job.
Acceptance criteria
- Decompression in the rehydration path is bounded by the expected plaintext size: a frame that expands past the manifest's
o.sizefor the object aborts with the existing 502HttpErrorshape, without materialising the full expansion (e.g. streaming/chunked decompression with a running total, or an up-front refusal when the frame's declared content size exceeds the expected size). - A frame whose expansion is exactly the expected size and whose sha256 matches is served exactly as today (control case unchanged); a short/legitimate frame is unaffected.
rehydrateactually uses the job'ssizefield (already selected atsrc/index.js:229); a job with a missing/non-numeric size fails closed rather than falling back to unbounded decompression.- A regression test in the worker test suite (
pkgs/cold-store-reaper/worker/test/, run bynpm test) crafts a high-expansion frame (small compressed size, claimed/actual expansion far beyond the expected size) and asserts the bounded refusal, alongside the existing local-proof and Range-ignored tests passing.
Activity
developing-today commentedon Nov 6, 2026
CODE-2007
dezren39 commentedon Nov 6, 2026
🤖 Agent note · filed
new-issue-creator-code-bnew-issue-creator-code-b, run 2026-11-06 11:50 CSTdezren39 commentedon Nov 7, 2026
Picked up by repo-worker-code-p (lane code-p, repo-queue worker shift, FALLBACK MODE — queue backend down: fleet queue health/claim failing HTTP 503 PGRST002, code#6619). Working issue #6590 under the worker runbook §0a fallback protocol.
15 remaining items
dezren39 commentedon Nov 7, 2026
🤖 Agent note · picked up
fleet queue healthHTTP 503 PGRST002, exit 4; outage tracked as issue infra: repo-queue PostgREST timeout: global failures lane-visible again — recurrence after #6450 closed (2026-11-06 21:15-21:31Z) #6619). Fallback claim on issue cold-store-reaper(worker): zstd decompression is unbounded — a small frame expands without limit before the sha256 check, and the manifest's expected plaintext size is selected but never used #6590.rehydratemust actually use the job'ssizefield (fail closed when missing/non-numeric), anddecompressFramemust abort past the expected size with the existing 502HttpErrorshape instead of materialising the full expansion. Regression test inpkgs/cold-store-reaper/worker/test/alongside the existing proof tests.queue/fallback-6590-bounded-decompress, laptop worktree~/git/fleet/fb-6590dezren39 commentedon Nov 7, 2026
Progress from
repo-worker-code-i: picked up: rehydrate/decoder read on current main — size is selected in SQL and posted in the job but never read; decompressFrame is a bare fzstd decompress(); next: worktree, inspect fzstd streaming API, implement bounded decompressiondezren39 commentedon Nov 7, 2026
Progress from
repo-worker-code-i: pr_opened: PR for issue #6590 opened (branch queue/fallback-6590-bounded-decompress, commit 9c5cf19); npm test fully green on laptop (local proof + range-ignored + 14 bounded-decompress checks), dist rebuilt; next: PR checks + Codex, then merge under standing criteriadezren39 commentedon Nov 7, 2026
Progress from
repo-worker-code-i: Codex P1 x2 on PR #6726 — dispositioning by fixing both: (1) frame-header pre-check bounding the header-driven window allocation + declared content size before streaming; (2) property-based decoder tests with named oracles incl. hand-crafted large-window frames. Not merging past undispositioned findings.Merge pull request #6726 from developing-today/queue/fallback-6590-bo…
dezren39 commentedon Nov 7, 2026
🤖 Agent note · done
fixed_merged— PR cold-store-reaper(worker): bound zstd decompression by the manifest expected size (#6590) #6726 merged (merge commit 7e903f6); this issue auto-closed by the merge.rehydratenow reads the job'ssize(already selected aso.size): missing/non-numeric size fails closed with a 502 before any fetch; the size bounds decompression.decompressFramestreams via fzstdDecompressin slices, counting output as produced: past the expected size the output is dropped andExpansionLimitErroris thrown (mapped to the existing 502 shape) — peak memory tracks the expected size, not the expansion. Exact-size frames with matching sha256 are served exactly as before.npm testin the worker package fully green on the laptop — local proof (real pack path), range-ignored (perf(cold-store-reaper): bound memory when Drive ignores Range requests #6182), and the new bounded-decompress suite (decoder + rehydrate levels).dist/worker.jsrebuilt.queue/fallback-6590-bounded-decompressdezren39 commentedon Nov 7, 2026
Released by
repo-worker-code-i(outcome: done). Outcome: fixed_merged. PR #6726 merged (merge commit 7e903f6); issue #6590 auto-closed. Rehydration decompression is bounded by the job size (validated, fail-closed 502 when missing/non-numeric); decoder streams with a running output bound, refuses oversized declared content size / declared window up front (max(limit, 8 MiB) window cap), and rejects concatenated frames. Three Codex P1 rounds all fixed in-PR, replied, and resolved; round 3 had no new findings. npm test fully green on laptop; dist rebuilt.