Repository navigation
fix(minvmd): add peer-credential check and provider-directory verification to minvmd control socket - #1853
Conversation
… minvmd control socket The minvmd control socket lacked peer credential checks and provider-directory verification, allowing any local process to connect and register boxes. Changes: - Add check_peer_credentials() using SO_PEERCRED (Linux) / getpeereid (macOS) on every control-socket connection - Add verify_provider_dir_ownership() to refuse bind when the provider directory is not owned by the daemon's uid or not 0700 - Deduplication logging: warn once per distinct foreign uid, debug thereafter - Unit tests for both checks - Integration tests (gated behind libkrun + MINVMD_E2E=1) Routing-Key: inbox-route/I_kwDOSUhdos8AAAABUs9W9g Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughminvmd now restricts and verifies the provider directory before binding the control socket. It checks each connection’s peer UID before reading a request and drops connections when credential checks fail or the UID does not match. ChangesControl socket access
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Client
participant serve_connection
participant PeerCredentialAPI
Client->>serve_connection: Open control-socket connection
serve_connection->>PeerCredentialAPI: Retrieve peer UID
PeerCredentialAPI-->>serve_connection: Return UID or credential error
serve_connection->>Client: Read request only if UID matches daemon effective UID
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The provider-path concern does not block merging. The peer-UID check remains in place before requests are read. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit checks the socket gate, Comment |
…d read StateDir::new creates the provider dir under the umask (0755) before the control socket binds, so refusing any non-0700 dir disabled the control socket on every existing install. Tighten a dir the daemon owns to 0700, then verify; a dir another uid owns is still refused. getpeereid writes the gid unconditionally, so the null gid pointer faulted on macOS on every connection. Pass a live gid. Split the uid decision from the socket read so the foreign-uid refusal is tested without root, use temp dirs instead of fixed /tmp paths, drop the VM integration tests (they ran 'minvmd boot', which never binds the control socket), fix the unused test imports clippy rejected, and record the same-uid trust model in the module docs.
…the control socket Recover a poisoned refusal-log lock instead of panicking, build ucred without zeroed(), add the missing SAFETY comment on geteuid, log a failed peer-credential read, and correct two comments that overclaimed (passed descriptors carry the connector's uid; a bad provider dir returns PermissionDenied rather than refusing to start).
norrietaylor
left a comment
There was a problem hiding this comment.
Approved per norrie's instruction: CodeRabbit approved, no open threads, independent review applied, lanes green.
|
/review |
|
Reviewed: 1 finding, none blocking at Address the comments on the diff. Clobber: none: |
norrietaylor
left a comment
There was a problem hiding this comment.
CodeRabbit approved at head, minimal-review advisory finding (LOW, debug log) answered, all lanes green.
The minvmd control socket lacked peer credential checks and provider-directory verification, allowing any local process to connect and register boxes.
Changes
check_peer_credentials()usesSO_PEERCREDon Linux andgetpeereidon macOS to verify the connecting process has the same uid as the daemon. Refused connections are logged once per distinct foreign uid (warn on first, debug thereafter) to avoid log flooding.restrict_owned_dir;StateDir::newcreates it 0755 under the umask, so a plain refusal would disable the control socket on every existing install), thenverify_provider_dir_ownership()refuses a dir owned by another uid or not 0700, naming the dir, owner, and mode.controlmodule docs: same-uid writers are accepted; a per-boot creator token is the pattern if rows must come only from the host-side creator (not built here).control_socket_admits_own_uid(real socket,SO_PEERCRED/getpeereid),control_socket_refuses_foreign_uid(uid decision, no root needed),bind_tightens_an_owned_provider_dir_to_0700, plussocktests for the dir verification and tightening.Verification
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABUs9W9g
Summary by CodeRabbit