devbox/internal/hub
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
..
blobstore round5-hub: fsck (at-rest blob integrity) + share ls 2026-06-30 15:28:02 -05:00
dashboard feat(hub): gc --dry-run, dashboard token auth, /healthz + /readyz 🛡️🧹 2026-06-30 12:14:54 -05:00
meta round3-hub: backup, metrics auth, device ls, gc --keep-days, access log 2026-06-30 13:53:16 -05:00
audit_test.go feat(M8a): adversarial auth audit — close +s escalation + add invite revocation 🛡️ 2026-06-23 20:27:12 -05:00
blob_traversal_test.go chore: prep for public release — MIT license + github.com module path 🌍⚖️ 2026-06-23 19:19:09 -05:00
events.go chore: prep for public release — MIT license + github.com module path 🌍⚖️ 2026-06-23 19:19:09 -05:00
join_pop_test.go chore: prep for public release — MIT license + github.com module path 🌍⚖️ 2026-06-23 19:19:09 -05:00
limits_test.go chore: prep for public release — MIT license + github.com module path 🌍⚖️ 2026-06-23 19:19:09 -05:00
server.go fix(hub): derive push chunk set from the manifest, not client-supplied req.Chunks 2026-06-30 15:28:02 -05:00
server_test.go fix(hub): derive push chunk set from the manifest, not client-supplied req.Chunks 2026-06-30 15:28:02 -05:00
sharename.go fix(M7): review fixes — pidfile O_EXCL, publish race, backoff reset 🐛 2026-06-23 01:37:58 -05:00
sharename_test.go fix(M7): review fixes — pidfile O_EXCL, publish race, backoff reset 🐛 2026-06-23 01:37:58 -05:00