Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Privileged bind helper #414

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukaslihotzki
Copy link
Contributor

When RUN_AS_USER is specified, fork off a small privileged helper that does nothing except binding to privileged ports, then immediately drop the privileges, even before starting the runtime.

The helper is small because it contains a tiny amount of code (50 "main" lines of code + 16 lines of code trivial struct mapping) and only uses 2 very basic dependencies (zerocopy and nix). This makes it very easy to audit.

@lukaslihotzki
Copy link
Contributor Author

A privileged helper to bind via unix sockets is the best solution for services with dynamic listeners, like stalwart-mail.

There are multiple suitable options on how to create that helper. This PR forks, Command::spawn the current binary would also work, or having two separate binaries (a privileged helper that calls Command::exec on the unprivileged main binary passing the unix socket). Having two binaries is optimal to limit supply chain attacks of libraries to the unprivileged user, but may be more complex for users. What do you think, @mdecimus?

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.

None yet

1 participant