wip: no root for wpa-supplicant#305722
Conversation
Of course it's desirable. Ideally no userspace service should run as root give that POSIX capabilities exist.
Nah, we're doing much worst with wpa_supplicant already. See the AllowAuxilliaryImperativeNetworks patch.
This is strange... there must be something going on with the permissions on the wpa_supplcicant socket file.
Well, there's no hurry: this will certainly have to wait for the 24.05 branch off. |
I had a look more into this, by adding verbose flags https://stackoverflow.com/a/60424409 suggests wpa_supplicant replies on a client-provided socket. Here's the code: https://w1.fi/cgit/hostap/tree/wpa_supplicant/ctrl_iface_unix.c#n205 . So what looks to be happening is that:
This makes sense: wpa-supplicant likely doesn't have access to the socket that wpa_cli (a private file owned by root?). I'm not sure what the expected working behaviour is here, to have wpa_cli work with an unprivileged wpa_supplicant. |
Yeah, strange design choice, though. |
|
I looked more into this. First, a bit of background on Unix domain datagram sockets. wpa_cli and wpa_supplicant use Unix domain SOCK_DGRAM sockets for their query-response type control interface. (Perhaps they use SOCK_DGRAM rather than SOCK_STREAM to benefit from SOCK_DGRAM's perserving message boundaries, making it easy to write a simple query-response protocol.) Per https://man7.org/linux/man-pages/man7/unix.7.html , wpa_cli must bind its socket to a filepath to receive replies. wpa_cli does that, binding to Per "Pathname socket ownership and permissions" of that man page, this socket must be writable by wpa_supplicant. wpa_cli doesn't change ownership of the socket it creates, so in this case, the socket is owned by root:root, and not writably by others, resulting in wpa_supplicant (running as use wpa-supplicant) being unable to send replies to wpa_cli.
AFAICT, wpa_cli isn't currently designed to work with an unprivileged wpa_supplicant (unless wpa_cli and wpa_supplicant run as the same user, as this PR's tests do). wpa_cli uses wpa_ctrl.c, which only does the necessary fchmod/lchown when #ifdef ANDROID: https://w1.fi/cgit/hostap/tree/src/common/wpa_ctrl.c?id=1dda619ed291edddf979d4513ddc59abf0a30c9e#n94 . I guess Android runs unprivileged wpa_supplicant , but doesn't use wpa_cli. To ensure users of wpa_cli are able to interact with unprivileged wpa_supplicant, I think wpa_cli would have to be changed to fchmod/lchown to g+rw and group wpa-supplicant. That'd require some upstream changes. Where does that leave us? Well I'm not sure of the full implications of only allowing execution of wpa_cli via I'll try to find some time to get this fixed upstream. References:
|
|
This isn't a bug. If anything, this is a wpa_supplicant feature request, and the NixOS issue tracker isn't the place for that. Closing. |
Description of changes
WIP running of wpa_supplicant using Linux capabilities rather than as a root process, as documented in https://w1.fi/cgit/hostap/tree/wpa_supplicant/README#n982 . The motivation is to reduce the privilege that this process has, in case it's exploited.
Tests are passing, but there's a few problems:
wpa_clifails when executed asroot@rnhmjoj thoughts on whether this change is desirable?
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.