sudo-project / sudo

Utility to execute a command as another user
https://www.sudo.ws
Other
1.16k stars 208 forks source link

`sudo -l cmd arg` is broken #249

Closed tik-stbuehler closed 1 year ago

tik-stbuehler commented 1 year ago

Given this entry:

nobody ALL = (root) NOPASSWD: /usr/bin/ping xxx

As nobody: sudo -l shows the command, but sudo -l /usr/bin/ping xxx fails; with debug output one can see this line:

user command "/usr/bin/ping /usr/bin/ping xxx" matches sudoers command "/usr/bin/ping xxx": false @ command_matches() ../../../plugins/sudoers/match_command.c:892

The handling for the list pseudo command prefixes the target command array with "list"; it adds a special case to extract the target binary at the new offset, but when there are arguments in sudoers to check it tries to match the arguments in the sudoers against the command arguments concatentation (which obviously fails).

sudo -l /usr/bin/ping xxx works when adding this entry:

nobody ALL = (root) NOPASSWD: /usr/bin/ping /usr/bin/ping xxx

Probably broken since a514a6eed5662ad6286408f70ca63e291dcbb5e5, but testing without install/suid got harder after -U was broken (#248), so I didn't bisect it.

Using tons of global vars without clear semantics (and #defineing normal looking var names into a global struct) and lots of special paths depending in which mode you run is just horrible.

I'm certainly looking for alternatives now, because I quite frankly think this implementation is doomed.

millert commented 1 year ago

Fixed in 1.9.13p3