Skip to main content

Linux sudo & Privilege

Status: Scaffold — content in progress

sudo allows non-root users to execute commands with elevated privileges based on the /etc/sudoers policy.

Sudoers Policy

username ALL=(ALL) ALL ← full sudo
%admins ALL=(ALL) NOPASSWD:ALL ← group, no password
user ALL=(ALL) /bin/systemctl ← restrict to specific command

Common Misconfigurations

MisconfigurationEscalation
NOPASSWD with ALLsudo as root without password
ALL=(ALL) with wildcard commandInject arguments to escape restricted command
Sudo with environment variables (env_keep)LD_PRELOAD → arbitrary code as root
Sudo to read filessudo less /etc/shadow → shell escape
Writable script called by sudoReplace script content

Telemetry

  • /var/log/auth.log or /var/log/secure: sudo usage
  • PAM logs: sudo authentication
  • auditd: syscall-level privilege use
TopicLink
Linux PAMlinux-pam