Commit graph

2 commits

Author SHA1 Message Date
f3f24feea9 harden: domain-separate the join challenge + inline pidfile wrapper (ponytail) 🪪♻️
Ponytail review of the hardening batch:
- JoinChallenge was a bare token||pubkey concat — unambiguous only because
  ed25519 keys are fixed 32 bytes. Now domain-separated + NUL-delimited
  ('devbox-join\0<token>\0<pubkey>') so the boundary is explicit regardless of
  key length, and the sig can't collide with any other devbox signing use.
- inlined the one-caller pidfileContents() into writePid.
(Kept the Linux /proc start-time guard: the daemon's real home is the Pi
cluster, where PID-reuse-after-crash is a genuine window; the magic field index
is already a named const. Declined the flock rewrite of fleet-verified code.)
2026-06-23 03:25:28 -05:00
f9c33d49d1 harden(pidfile): guard against PID reuse with a start-time token 🆔
A crashed daemon's PID can be recycled by an unrelated process, so the bare-PID
pidfile let 'devbox stop' SIGTERM a stranger and 'devbox start' refuse over a
reused PID. The pidfile now records '<pid> <starttoken>' (Linux /proc/<pid>/stat
field 22 start time); runningPid only treats the PID as our daemon when the
token still matches. Falls back to bare-PID liveness where the token is
unverifiable (non-Linux) — no regression. Verified on real linux/arm64.
[fanned-out subagent: harden-pidfile]
2026-06-23 03:00:30 -05:00