Remember, it's just a suggestion.
@folbricht
Dealing with network namespaces using setns() requires CAP_SYS_ADMIN, it could be dangerous if the program has unknown bugs and vulnerabilities, that's why an alternative approach is needed.
There is a socket library called xsocket, it is a socket library that can use a cross-netns fashion to avoid requiring elevated privileges such as CAP_SYS_ADMIN, the only need of a root access is running the library server itself, which is by far more secure and trusty as it a very small program and have a minimal attack surface area:
ip netns exec foo sudo -u bar -- xsocket-server /tmp/xs-socket
nsenter -t 1234 -n -- sudo -u bar -- xsocket-server /tmp/xs-socket
I know that is a little known project, but it's promising. The only security notes on using this protocol is adjusting the user/group/chmod permissions and ACLs on the xsocket-server Unix sockets.
I'm sending an attachment that contains two reference implementations of how to implement xsocket protocol in Go (don't laugh, it's AI):
xsocket_pf.zip
Remember, it's just a suggestion.
@folbricht
Dealing with network namespaces using setns() requires CAP_SYS_ADMIN, it could be dangerous if the program has unknown bugs and vulnerabilities, that's why an alternative approach is needed.
There is a socket library called xsocket, it is a socket library that can use a cross-netns fashion to avoid requiring elevated privileges such as CAP_SYS_ADMIN, the only need of a root access is running the library server itself, which is by far more secure and trusty as it a very small program and have a minimal attack surface area:
ip netns exec foo sudo -u bar -- xsocket-server /tmp/xs-socketnsenter -t 1234 -n -- sudo -u bar -- xsocket-server /tmp/xs-socketI know that is a little known project, but it's promising. The only security notes on using this protocol is adjusting the user/group/chmod permissions and ACLs on the
xsocket-serverUnix sockets.I'm sending an attachment that contains two reference implementations of how to implement xsocket protocol in Go (don't laugh, it's AI):
xsocket_pf.zip