PID-identity hardening (PR #86, @ynaamane)
17-bug audit of guard.py's PID management. 5 confused-deputy attack vectors where recycled PIDs caused SIGTERM of unrelated processes (Slack, VS Code, browser). All signal-sending paths now gated on identity verification.
Key fixes:
_is_claude_process()+_is_cozempic_guard_process()+_is_cozempic_watcher_process()— argv-based identity checks before everyos.kill()- Atomic pidfile via
O_CREAT|O_EXCL— prevents TOCTOU race on daemon start _detect_claude_flags— psutil-based with metachar filtering (blocks$(rm -rf /)in process argv)- Windows cmd metachar escaping for resume commands
- Main watchdog loop verifies Claude PID identity on every cycle (catches mid-session PID recycling)
Follow-up fixes:
os.openfd leak onos.writefailure — now try/finallyspawn_lockleak onsubprocess.Popenfailure — previously blocked all future spawns permanently
Review: 4 independent agents (security/backdoor, logic/correctness, dry-run emulation of 8 scenarios, test coverage). No backdoors. No injection vectors.
637 tests passing.