Repository navigation
Close the UDS socket bind-to-chmod race in the daemon - #1548
Conversation
UnixListener::bind creates the socket file honoring the process's ambient umask; the subsequent set_permissions(0o600) call left a window where the socket could be group/other-reachable on a permissive-umask system. Narrow the umask to 0o177 for the duration of the bind so the socket is owner-only from the instant it appears, per ADR-052 §3. Applied to both the headless and tray-driven server loops via a shared helper. Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis is a clean, well-scoped fix for the UDS bind→chmod race described in ADR-052 §3 and issue #1506. The This is a net positive and addresses the acceptance criteria in #1506. I have one blocking-adjacent correctness note (asterisked below as an Improvement, not a Blocker, since it doesn't reopen the security window) and a couple of nits. FindingsCritical IssuesNone. The core security property — no window where the socket is exposed at the ambient umask — is delivered correctly:
Suggested Improvements
Nitpicks
Verification Performed
RecommendationApprove. This is a focused, correct fix for the stated problem, matches existing dependency patterns, has a passing regression test, and does not bundle unrelated changes. The one improvement noted (stale socket file on |
malibio
left a comment
There was a problem hiding this comment.
Review complete — net positive, recommend merge. See detailed findings in the PR comment above. No blocking issues; one non-blocking improvement noted (stale socket file if set_permissions fails post-bind) and two nits. Clippy/fmt clean, test passes, scope correctly excludes peer-cred/Windows work (tracked separately under #1498).
Reviewer noted the SAFETY comment's concurrency argument was really a caller precondition, not something the function enforces. Moved it into the doc comment and named which two call sites satisfy it. Skipped two other suggestions as non-blocking: the stale-socket-file edge case on set_permissions failure (already self-healing via the next startup's remove_file, not a security issue), and the reviewer's own note that current test coverage is "fine as-is." Co-Authored-By: Claude <[email protected]>
Addressed Review Feedback✅ Addressed (1):
⏭️ Skipped (2, both explicitly non-blocking suggestions):
No 🔴 Critical or 🟡 Important findings were raised — the review's recommendation was to merge as-is. Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The only change made is a documentation/comment edit (no logic change) in response to a non-blocking nit. Verified |
Closes #1506