The device id is derived from the pubkey in JoinRequest, but the hub never
checked the joiner actually held that key — anyone with a token could enroll
claiming another device's identity. Now the client signs JoinChallenge(token,
pubkey) with its ed25519 private key and the hub verifies it (ed25519.Verify)
BEFORE redeeming the token — so a bad request can't burn a legitimate one-time
token either. proto gains a Signature field + the shared JoinChallenge helper.
Regression test: garbage/missing/wrong-key sigs all 401, token survives, valid
join enrolls.
Two ways a buggy/malicious hub could corrupt the local tree:
- writeEntry/deleteFile joined hub-supplied Entry.Path into root with no
containment check, so '../../.ssh/authorized_keys' wrote/deleted OUTSIDE the
mount. New safeJoin() uses filepath.IsLocal to refuse absolute/.. /escaping
paths before any write or delete.
- GetBlob returned bytes with only an HTTP-status check. Blobs (chunks AND
manifests) are content-addressed, so now verify chunk.Hash(body)==hash —
a corrupt/truncated transfer or hostile hub can't write wrong content
undetected. (manifest ID == chunk.Hash(Marshal()), so the check holds there.)
Regression tests for both.
- pkg/proto + internal/hub/events.go: SSE /v1/events with a broker; hub broadcasts
on genuine head ADVANCE only (idempotent re-push doesn't broadcast -> no storm)
- transport.Client.Events: SSE consumer (timeout-less, ctx-cancelled)
- internal/daemon: per-mount loop funnels watcher + SSE triggers into a serialized
Sync; read-only mounts pull-only; base snapshot persisted in state.json
- cmd/devbox: 'mount <share> <dir> [--ro]' (clone+sync) and 'start' (foreground daemon)
- fix: serialize chunk.Split — jotfs/fastcdc-go mutates a package global in
NewChunker, racing under concurrent chunking (caught by -race)
- test: two live daemons, an edit on one reaches the other automatically (race-clean)