I'm looking for a way to allow a user to install (only remote) packages via apt-get
(or another mechanism?) but not allow them to run arbitrary commands as root.
I can get some of the way there via /etc/sudoers. Say I have this in my /etc/sudoers file
root ALL=(ALL:ALL) ALL
john ALL=NOPASSWD:/usr/bin/apt,/usr/bin/apt-get
Then John appears limited to run apt
and apt-get
via sudo
. But... there do seem to be ways to escape apt-get
to a shell as root (https://blog.ikuamike.io/posts/2021/package_managers_privesc/):
- Type
sudo apt-get changelog apt
and hit enter - Type an exclamation mark
!
and hit enter - You’re now in the shell as root and can do anything
Or run the below:
sudo apt update -o APT::Update::Pre-Invoke::="/bin/bash"
If it makes any difference, this is in Docker
Was posted at https://superuser.com/q/1698692/315568, but I think that was the wrong site, since this isn't (just) for my machine, but for others