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

systemd: tight sandboxing #103

Merged
merged 1 commit into from
Mar 18, 2024
Merged

systemd: tight sandboxing #103

merged 1 commit into from
Mar 18, 2024

Conversation

jdek
Copy link
Contributor

@jdek jdek commented Mar 18, 2024

wireproxy needs very little permissions, we can restrict it to basically nothing. DynamicUser means the system will generate a UID on demand for service, also CAP_NET_BIND_SERVICE can be used to allow this user to bind to a port < 1024 if desired. LoadCredential lets us read a file with tight permissions i.e. root:root 0400 and pass it to only wireproxy in an ephemeral and constrained manner.

wireproxy needs very little permissions, we can restrict it to basically
nothing. DynamicUser means the system will generate a UID on demand
for service, also CAP_NET_BIND_SERVICE can be used to allow this user
to bind to a port < 1024 if desired. Also LoadCredential lets us read
a file with tight permissions i.e. root:root 0400 and pass it to only
wireproxy in an ephemeral and constrained manner.

Signed-off-by: J. Dekker <[email protected]>
@pufferffish
Copy link
Owner

This is interesting, for OpenBSD wireproxy would automatically use pledge and unveil to limit its privileges. I think it would be worth it if we also have something similar for Linux but not just in systemd as well. I believe something similar can be achieved with seccomp but I haven't looked into it.

@pufferffish pufferffish merged commit 4f066d0 into pufferffish:master Mar 18, 2024
10 checks passed
@villepeh
Copy link
Contributor

villepeh commented Apr 2, 2024

Thanks for these improvements! I'm not a pro with systemd units so I'm glad someone took a look

Choraden added a commit to saucelabs/forwarder that referenced this pull request Apr 8, 2024
Forwarder does not need that many permissions, we can restrict it to minimum.

CAP_NET_BIND_SERVICE can be used to allow this user to bind to a port < 1024 if desired.

The work is based on wireproxy's systemd configuration[1]. Also I found systemd service hardening doc[2] helpful.

DynamicUser/Strict system protection didn't work as package installs forwarder binary at /usr/bin.

[1] pufferffish/wireproxy#103.
[2] https://gist.github.com/ageis/f5595e59b1cddb1513d1b425a323db04
Choraden added a commit to saucelabs/forwarder that referenced this pull request Apr 8, 2024
Forwarder does not need that many permissions, we can restrict it to minimum.

CAP_NET_BIND_SERVICE can be used to allow this user to bind to a port < 1024 if desired.

The work is based on wireproxy's systemd configuration[1]. Also I found systemd service hardening doc[2] helpful.

DynamicUser/Strict system protection didn't work as package installs forwarder binary at /usr/bin.

[1] pufferffish/wireproxy#103.
[2] https://gist.github.com/ageis/f5595e59b1cddb1513d1b425a323db04
mmatczuk pushed a commit to saucelabs/forwarder that referenced this pull request Apr 8, 2024
Forwarder does not need that many permissions, we can restrict it to minimum.

CAP_NET_BIND_SERVICE can be used to allow this user to bind to a port < 1024 if desired.

The work is based on wireproxy's systemd configuration[1]. Also I found systemd service hardening doc[2] helpful.

DynamicUser/Strict system protection didn't work as package installs forwarder binary at /usr/bin.

[1] pufferffish/wireproxy#103.
[2] https://gist.github.com/ageis/f5595e59b1cddb1513d1b425a323db04
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.

3 participants