Program Misuse
Privilege Escalation
Yan Shoshitaishvili
Arizona State University
Recall the Linux permission model
Every process has a user ID and a GID.
Every file and directory is owned by a user and group.
Child processes inherit from parent processes.
Some UIDs are better than others...
UID 0 is the Linux administrator user, root. Roughly speaking, you need root for:
But if you're UID 1000, how do you become UID 0?
Privilege Elevation
One way to elevate your privileges is to run an suid binary.
SUID is a bit in the Linux permission model:
SUID: execute with the eUID of the file owner rather than the parent process.
SGID: execute with the eGID of the file owner rather than the parent process.
Sticky: used for shared directories to limit file removal to file owners.
Common examples of SUID binaries: sudo, su, newgrp
SUID
User Read
User Write
User Exec
Group Read
Group Write
Group Exec
World Read
World Write
World Exec
Sticky
SGID
Quick Detour: e UID?
Three different type of user and group IDs:
Effective (eUID, eGID): the UID/GID used for most access checks.
Real (UID, GID): the "real" UID (or GID) of the process owner, used for things such as signal checks.
Saved: a UID/GID that your process could switch its eUID/eGID to. Used for temporarily dropping privileges.
With great power comes great responsibility...
eUID 0 is powerful. Aside from system management, root can (by default):
Open any file!
Execute any program.
Assume any other UID or GID.
Debug any program.
Obviously, this can be a security disaster...
Privilege Escalation
Privilege Escalation is a class of exploit in which the
attacker elevates their privileges to (generally) root level.
Typical flow:
Example: if an SUID binary has a security problem, an attacker can use it in a privilege escalation attack:
Security Woes
Who would be this careless?
Practice Problems!
This module's practice problems:
Let's demo a few: