
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
72
|
Chapter 3: Hardening Linux and Using iptables
This causes that command to run not with the privilege level of the user who exe-
cuted it but of the user or group who owns that command. If the owner’s user or
group ID is 0 (root), the command will run with superuser privileges no matter who
actually executes it. Needless to say, this is extremely dangerous!
The SUID and SGID bits are most often used for commands and daemons that
normal users might need to execute but that also need access to parts of the filesys-
tem not normally accessible to those users. For some utilities like su and passwd,
this is inevitable: you can’t change your password unless the command passwd can
alter /etc/shadow (or /etc/passwd), but obviously, these files can’t be directly writ-
able by ordinary users. Such utilities are very carefully coded to make them nearly
impossible to abuse.
Some applications that run SUID or SGID have only limited need of root privileges,
while others needn’t really be run by unprivileged users. For example, mount is com-
monly run SUID root, but on a server-class system, there’s no good reason for any-
body but root to be mounting and unmounting volumes, so mount can therefore
have its SUID bit unset.
Identifying and dealing with SUID root files
The simplest way to identify files ...