Skip to content

systemd: restrict permissions#778

Merged
mmatczuk merged 2 commits intomainfrom
hg/systemd_privileges
Apr 8, 2024
Merged

systemd: restrict permissions#778
mmatczuk merged 2 commits intomainfrom
hg/systemd_privileges

Conversation

@Choraden
Copy link
Contributor

@Choraden Choraden commented 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] windtf/wireproxy#103.
[2] https://gist.github.com/ageis/f5595e59b1cddb1513d1b425a323db04

Choraden added 2 commits April 8, 2024 12:09
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] windtf/wireproxy#103.
[2] https://gist.github.com/ageis/f5595e59b1cddb1513d1b425a323db04
Running systemd service in a container is not very common. We use it for testing, however it has its disadvantages.
Some container runtimes prohibit creating UTS namespaces. That leads to a warning:
"forwarder.service: ProtectHostname=yes is configured, but UTS namespace setup is prohibited (container manager?), ignoring namespace setup."
Giving a container privileged mode fixes this issue.
@mmatczuk mmatczuk merged commit 31f7ce4 into main Apr 8, 2024
@mmatczuk mmatczuk deleted the hg/systemd_privileges branch April 8, 2024 10:22
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