Harden daemon: fail closed when COVEN_HOME or the socket is owned by another user#148
Open
maplesyzzurp wants to merge 1 commit into
Open
Harden daemon: fail closed when COVEN_HOME or the socket is owned by another user#148maplesyzzurp wants to merge 1 commit into
maplesyzzurp wants to merge 1 commit into
Conversation
…owned docs/AUTH.md's "Current hardening gap" requires the daemon to refuse state that is "not owned by the current user". OpenCoven#144 added the symlink / non-socket checks from that list; this adds the missing ownership leg. ensure_private_coven_home and bind_api_socket now reject an existing COVEN_HOME or socket whose owner uid differs from the daemon's effective uid — before creating, chmod-ing, or removing it — so another local user cannot pre-plant the socket, status, or SQLite ledger. The owner comparison is a pure helper, unit-tested without a root-owned fixture. std + libc only.
This was referenced May 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the ownership leg of the
docs/AUTH.md"Current hardening gap". That section says the daemon should fail closed whenCOVEN_HOME"is not owned by the current user" (L131) and that the socket root/dir/socket "must be owned by the current user" (L99). #144 landed the symlink / non-socket checks from the same list; this adds the missing ownership check.What
ensure_private_coven_homeandbind_api_socketnow refuse an existingCOVEN_HOMEor socket whose owner uid differs from the daemon's effective uid — before creating,chmod-ing, or removing it. Without it, another local user who can write the parent directory could pre-plant the socket / status file / SQLite ledger for the daemon to adopt or replace.How
A small pure helper
check_owned_by_current_user(path, owner_uid, euid)bails on mismatch; callers passmetadata.uid()andlibc::geteuid(). Keeping the comparison pure makes the refusal unit-testable without a root-owned fixture (which CI can't create).std+libconly — no new dependencies.unsafe { libc::geteuid() }(always-safe FFI read; matches existinglibcuse in this file).0o700/0o600; ownership is the piecechmodcan't fix.Tests
cargo test --workspacegreen,clippy -D warningsclean,fmtclean.Opened against the contribution freeze as a focused security fix, in the same vein as #144 / #145.