brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: getent group sudo lists everyone with admin rights, a two second security check

Security
~/tips/tip-security-getent-group-sudo-admins

getent group sudo adm docker lxd

Shows which accounts are in the groups that grant sudo or root access.

On Ubuntu and Debian you get sudo by being in the group sudo. So the quickest admin audit is asking who is in it.

getent asks the same name service that logins use, so it also finds members that come from LDAP or another directory:

getent group sudo
getent group sudo adm docker lxd

The answer is one line per group, with the members after the last colon. A few more groups are worth a look while you’re there. adm can read most logs, and anyone in docker or lxd can start a privileged container and become root without ever typing a sudo password.

There is a gap here that catches people. A user whose primary group is sudo does not appear in that member list, because primary groups live in /etc/passwd. This finds those as well:

awk -F: -v g="$(getent group sudo | cut -d: -f3)" '$4 == g {print $1}' /etc/passwd

And a group is only half of it. Rules in /etc/sudoers and /etc/sudoers.d/ can give rights to single users too, so I’d follow this up with sudo -l -U name for anybody who looks unexpected.

Further reading: getent(1) manual page, Docker post-install steps (docker group)

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link