Pcornel
Linux · Permissions & Ownership

SUID

Cheat sheet · https://pcornel.dk/topic.php?topic=2708

Back to the Topic

Answer

SUID (set-user-ID, mode 4xxx, s in the owner execute position) makes a program run with its file owner's privileges — e.g. /usr/bin/passwd runs as root to update /etc/shadow.

Remember

SUID on a script is ignored by Linux; it only works on binaries. Every SUID-root binary is an attack surface — audit them and remove the bit where not needed. Mount options nosuid disable it on a filesystem.

First checks

  • find / -xdev -perm -4000 -type f — SUID files
  • ls -l <path> — owner, group and mode
  • stat -c '%A %a %U:%G' <path> — symbolic and numeric mode with owner
  • namei -l <path> — permissions of every directory on the path
  • id <user> — user's groups

Commands

sudo
mount
ping

Verify in this order

binary with SUID bit executed → process gets the file owner's effective UID → runs with that privilege

Where it usually breaks

First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2708

Confirmation

Confirm action

Continue?