Skip to content

Refuse to run rdc serve with root privileges - #15

Closed
bscott wants to merge 7 commits into
mainfrom
release/0.5.0
Closed

bscott wants to merge 7 commits into
mainfrom
release/0.5.0

Conversation

@bscott

@bscott bscott commented Oct 7, 2026

Copy link
Copy Markdown
Owner

What

Added a new privdrop module that prevents rdc serve from running with root privileges (real or effective uid 0). The daemon now exits early with a clear error message if started as root, via sudo, or as a setuid binary. rdc doctor reports the current process user and flags root as unhealthy.

Why

rdc serve never needs root privileges: the port is unprivileged and all other operations happen within a desktop session. Running with root privileges creates an unnecessary security risk—a remote-control surface should not hold full system privileges. This change enforces that invariant and makes the constraint explicit to users.

The implementation checks both real and effective uid, since either one being 0 grants root authority. A process with uid 0 can regain effective uid 0, and a setuid-root binary has effective uid 0 regardless of who ran it.

Tests

Added comprehensive unit tests covering:

  • Ordinary users pass the check
  • Real uid 0 is refused
  • Setuid-root binaries (uid != 0, euid == 0) are refused
  • Root with dropped effective uid (uid == 0, euid != 0) is refused
  • Platforms without uids (Windows) are not considered root
  • User name resolution on Unix (uid 0 → "root")
  • Proper formatting of user descriptions with uid/euid

All tests pass; cargo test validates the logic without requiring elevated privileges.

Ran on

  • Linux (x86_64): Verified unit tests pass and logic handles both real and effective uid correctly
  • The code is Unix-specific for uid checks; Windows path returns non-root and uses USERNAME env var

Checklist

  • Tests included; cargo test passes
  • cargo fmt and cargo clippy --all-targets -- -D warnings pass
  • Docs updated (SECURITY.md, docs/setup-linux.md, README.md)
  • CHANGELOG.md entry under Unreleased
  • Commits signed off

https://claude.ai/code/session_01H6FWzFP6qZXMn5TXipJPRw

Mrigbozurike and others added 7 commits September 14, 2026 06:47
Signed-off-by: mrigbozurike <drbillionbook@gmail.com>
Signed-off-by: mrigbozurike <drbillionbook@gmail.com>
Signed-off-by: mrigbozurike <drbillionbook@gmail.com>
Merges #4 (audit: record focused window title and screenshot hash) at 7e07e04. The only conflict is CHANGELOG.md, where #4 and #5 both add an entry under Unreleased; both are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H6FWzFP6qZXMn5TXipJPRw
Signed-off-by: Brian Scott <claudeai@bscott.email>
Merges #3 (systemd: sandbox the user unit) at fc66dbf. Conflicts: CHANGELOG.md (each PR adds an entry under Unreleased; all are kept) and docs/setup-linux.md (#3 and #5 add sections at the same place; both are kept, the unit's sandbox section first under Running, then Persistence is opt-in).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H6FWzFP6qZXMn5TXipJPRw
Signed-off-by: Brian Scott <claudeai@bscott.email>
Merge #4 and #3 into release/0.5.0 (conflicts resolved)

bscott commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

Closing. This PR was opened before 0.5.0 was ready: it described only #5, and the release commit (version bump, dated CHANGELOG) wasn't in yet. A new release PR from release/0.5.0 to main will follow once that commit is in.


Generated by Claude Code

@bscott bscott closed this Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants