Unknown SUID files
HighL07Linux serversFind 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/nullBe suspicious of anything under /tmp, /home, /var/www or /dev/shm, or any name you do not recognise.
Debian / Ubuntu
dpkg -S /path/to/fileA package name means it comes from the distribution. no path found means no package owns it.
RHEL / Rocky / Alma
rpm -qf /path/to/fileHow to fix
Linux
sudo chmod u-s /path/to/fileRemove 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 --verifyLists package files that have been changed.
RHEL / Rocky / Alma
sudo rpm -VaHow 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/nullRun the downloaded check again and make sure this item passes.