Skip to content

fix(protector): refuse to bind a sidecar above the offline-verify ceiling - #363

Open
DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/sidecar-bind-read-cap
Open

DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/sidecar-bind-read-cap

Conversation

@DeryFerd

@DeryFerd DeryFerd commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

The sidecar bind path and the sidecar verify path disagreed on size. verify-sidecar caps a sidecar entry at MAX_SIDECAR_ENTRY_BYTES (256 MiB) and fails closed above it, but protectTarget's collectSidecarBindings read every requested sidecar with a plain readFileSync and bound it with no ceiling at all. A caller that pointed sidecarEntanglePaths at a sparse file, a mistyped glob or a file that had grown past a few gigabytes got a protect run that succeeded and planted a binding its own verifier would then refuse to read.

What changed

  • collectSidecarBindings in src/engine/protector.ts now stats each sidecar before reading it and skips, into the existing sidecarEntangleSkipped list, anything above MAX_SIDECAR_ENTRY_BYTES. It reuses the constant the verifier already enforces instead of introducing a second number.
  • Because the skip goes through the same list the rest of the entanglement path already populates, a caller sees the oversized path named in sidecarEntangleSkipped rather than discovering the problem later at verify time.
  • tests/sidecar-entangle-skipped-paths.test.ts gains a case that creates a sparse sidecar one byte past the ceiling and asserts it is reported skipped instead of being bound.

Why this matters

Write and read should agree. If the verifier refuses to read a sidecar, protect should not plant it, and the failure should surface as a named skip rather than an out-of-memory read or a binding that only breaks on the verify pass. Every other reader in the engine already bounds itself, so this brings the bind path in line.

Tests

  • npx vitest run tests/sidecar-entangle-skipped-paths.test.ts tests/verify-sidecar.test.ts tests/sidecar-entangle-plan.test.ts tests/sidecar-entangle-protect.test.ts tests/hardening-engine.test.ts passes, 40 tests.

Compatibility

A sidecar under 256 MiB binds exactly as before. An oversized sidecar that used to be read whole and bound is now reported in sidecarEntangleSkipped, which changes a silent success into an explicit skip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant