Insecure (100)
Privilege escalation through SUID files and PATH variable manipulation
Last updated
Privilege escalation through SUID files and PATH variable manipulation
Last updated
Someone once told me that SUID is a bad idea. Could you show me why?
The binary calls the id
command three times, first without privileges, then as root, then again without privileges.
Since the SUID flag is set, we can manipulate the PATH variable to execute arbitrary code when id
is called. The goal is to read the flag.txt
file which requires root access. Thus, we need to spawn a shell as root.
The following bash script will only spawn the shell if the caller is root.
Translating this into a one liner and creating our malicious id
payload:
PATH variable manipulation:
After running insecure
, we obtain a root shell: