Tools
Log in
English

Learn to codeSecurity check

Unknown SUID files

HighL07Linux servers

Find SUID files, which run with the owner (root) rights, that do not belong to…

What is the risk

A SUID file runs with its owner rights no matter who starts it. After getting root, attackers hide a SUID shell to come back easily.

Normal SUID files (passwd, sudo, pkexec) can also be abused when they have a bug (CVE-2021-4034 in pkexec).

How to check

Linux

sudo find / -xdev -perm -4000 -type f -ls 2>/dev/null

Be suspicious of anything under /tmp, /home, /var/www or /dev/shm, or any name you do not recognise.

Debian / Ubuntu

dpkg -S /path/to/file

A package name means it comes from the distribution. no path found means no package owns it.

RHEL / Rocky / Alma

rpm -qf /path/to/file

How to fix

Linux

sudo chmod u-s /path/to/file

Remove SUID only where it is not needed. An unknown SUID file outside any package is a sign of a break-in, so copy it first and check the whole server.

Debian / Ubuntu

sudo dpkg --verify

Lists package files that have been changed.

RHEL / Rocky / Alma

sudo rpm -Va

How to prevent it

  • Mount /tmp, /dev/shm and /home with nosuid (L11).
  • If you do not use pkexec, sudo chmod u-s /usr/bin/pkexec removes its SUID bit.

Check again after fixing

Linux

sudo find / -xdev -perm -4000 -type f -ls 2>/dev/null

Run the downloaded check again and make sure this item passes.

Related CVEs

HighCVE-2021-40347.8

Security check home