Skip to content

feat(sandbox): drop root privileges after initialization on macOS#457

Merged
domcyrus merged 1 commit into
mainfrom
macos-uid-drop
Jul 9, 2026
Merged

feat(sandbox): drop root privileges after initialization on macOS#457
domcyrus merged 1 commit into
mainfrom
macos-uid-drop

Conversation

@domcyrus

@domcyrus domcyrus commented Jul 8, 2026

Copy link
Copy Markdown
Owner

macOS counterpart of #456. Under sudo, rustnet kept euid 0 for its whole lifetime even though root is only needed to open the BPF/PKTAP capture devices.

After capture init the process now drops to SUDO_UID/SUDO_GID (or nobody for plain root), before Seatbelt is applied so the profile needs no setuid allowances. Pre-created export files are chowned to the target user so PCAP/JSONL reopens keep working. Opt out with --no-uid-drop or --no-sandbox; --sandbox-strict fails if the drop fails.

The default PKTAP attribution path is unaffected (process metadata arrives in-band on the open capture fd); the lsof fallback then only sees the target user's processes (documented in SECURITY.md).

Verified on macOS 26.5: sudo run at uid 501 with Seatbelt fully enforced and exports written post-drop, nobody fallback (-2) for plain root, and --no-uid-drop keeping root. fmt/clippy/tests clean; Linux build cross-checked.

Rebased on main after #456: the uid-drop wiring in cli.rs/main.rs is now shared with Linux (privdrop re-exported at the platform level). Expect a trivial conflict with #458 for whichever merges second; I'll rebase.

@domcyrus domcyrus merged commit d876b0a into main Jul 9, 2026
21 checks passed
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.

1 participant