tlshd currently requires being executed as root:
|
#define TLSHD_OWNER 0 /* root */ |
This is a lot of privilege, which OWASP describes as its second top risk: https://owasp.org/Top10/2025/A02_2025-Security_Misconfiguration/.
It'd be great if tlshd could run with fewer privileges.
Some ideas to reduce privilege:
- Allow running as a non-privileged user, and document that the process must have CAP_NET_ADMIN, which is sufficient for the privileged netlink operations.
- Perhaps keyring integration requires other capabilities, but I noticed tlshd seemed to work even without keyring integration. I don't know if that has security implications...
- Implementation: Replace
|
#define TLSHD_OWNER 0 /* root */ |
with getuid.
- Hardening with namespaces/seccomp/landlock/etc.
- The main goal being to limit CAP_NET_ADMIN, e.g. syscall filtering.
- Implementation: systemd sandboxing. I have a working example.
- systemd's RestrictAddressFamilies to AF_NETLINK prevent the process interfering with AF_INET or AF_UNIX.
- SystemCallFilter to @System-service likely restricts some privileged syscalls.
- Run each TLS handshake as an unprivileged user, in a privileged parent/unprivileged child model, similar to http://www.citi.umich.edu/u/provos/ssh/privsep.html * The benefit is that an unprivileged process is the one doing the parsing of the untrusted packets.
- This might involve
tlshd_service_socket doing a setuid/setgid to an unprivileged user, and then passing the handshake params to the parent (via SCM_RIGHTS), and having the parent call tlshd_genl_put_handshake_parms (which I guess is the thing that actually needs privilege). O
- This could be fiddly.
I think a sweet spot is (1) and (2).
tlshd currently requires being executed as root:
ktls-utils/src/tlshd/config.c
Line 226 in 4d4045b
This is a lot of privilege, which OWASP describes as its second top risk: https://owasp.org/Top10/2025/A02_2025-Security_Misconfiguration/.
It'd be great if tlshd could run with fewer privileges.
Some ideas to reduce privilege:
ktls-utils/src/tlshd/config.c
Line 226 in 4d4045b
tlshd_service_socketdoing a setuid/setgid to an unprivileged user, and then passing the handshake params to the parent (via SCM_RIGHTS), and having the parent call tlshd_genl_put_handshake_parms (which I guess is the thing that actually needs privilege). OI think a sweet spot is (1) and (2).