devbox/internal
shoemoney f0fe810ab6
Some checks are pending
CI / vet-build-test (push) Waiting to run
fix(hub): derive push chunk set from the manifest, not client-supplied req.Chunks
Trust boundary: handlePush previously verified that every hash in req.Chunks
existed in the blob store, but it trusted req.Chunks as the authoritative list
of chunks the pushed manifest references.  A buggy or malicious client could:

  (a) Push a manifest referencing chunk C while omitting C from req.Chunks →
      hub commits a snapshot whose manifest references a blob that may not
      exist → every subsequent pull 404s on C (dangling snapshot).

  (b) Include in req.Chunks a chunk not referenced by the manifest →
      refcount is bumped for a blob GC can never safely collect (phantom ref).

Fix: after confirming the manifest blob is present, we now fetch + unmarshal
it and derive the DISTINCT chunk hash set directly from Manifest.Entries[*].Chunks.
Each hash in that set is verified to exist in the store; any missing hash rejects
the push with 409 (same status as before).  Only manifest-referenced hashes are
passed to db.AddSnapshot() for refcounting.

Size hint: meta.ChunkRef.Size is used only for metrics/dashboard totals and is
stored once (first INSERT; ON CONFLICT only bumps refcount, not size).  GC
decisions are made on refcount, not size.  We keep req.Chunks as a size-hint
lookup (reqSizes map): if the client is honest the size is correct; if a hash is
absent from req.Chunks the size defaults to 0, which is harmless.

Happy-path unchanged: an honest client (syncer.go) always derives req.Chunks
from the same manifest, so all hashes are present with correct sizes.

Tests: TestHubHappyPath updated to push a real manifest JSON (required now that
the hub parses it); TestPushManifestChunkIntegrity asserts the malicious pattern
is rejected and the head does not advance, then confirms an honest push succeeds.
2026-06-30 15:28:02 -05:00
..
chunk feat(device): --json output, streaming chunker, pause --for, per-mount exclude, rescan knob ✨ 2026-06-30 12:29:02 -05:00
config feat(cli): doctor --json, conflicts --rm, status sync-age, opt-in default ignores 🧰🙈 2026-06-30 13:26:24 -05:00
control round4-client: surface last sync error per mount in status 2026-06-30 14:23:42 -05:00
daemon round4-client: surface last sync error per mount in status 2026-06-30 14:23:42 -05:00
hooks refactor(M7): cmp.Or for editor env, share hooks.Executable (ponytail) ♻️ 2026-06-23 01:32:22 -05:00
hub fix(hub): derive push chunk set from the manifest, not client-supplied req.Chunks 2026-06-30 15:28:02 -05:00
identity feat(M2): wire protocol foundation 🔌 2026-06-22 23:30:01 -05:00
ignore feat(cli): doctor --json, conflicts --rm, status sync-age, opt-in default ignores 🧰🙈 2026-06-30 13:26:24 -05:00
manifest feat(device): --json output, streaming chunker, pause --for, per-mount exclude, rescan knob ✨ 2026-06-30 12:29:02 -05:00
secret chore: prep for public release — MIT license + github.com module path 🌍⚖️ 2026-06-23 19:19:09 -05:00
syncer feat(transfer): harden the WAN sync path — timeouts, retry, parallel I/O, download gzip 🌐⚡ 2026-06-30 13:15:17 -05:00
transport round3-client: doctor clock-skew check vs hub 2026-06-30 13:53:16 -05:00
watch fix: foundation hardening from review pass 🛡️ 2026-06-22 23:24:55 -05:00