tl;dr
This is a rumination about habits and cybersecurity. Overlooking permission misconfigurations during pentesting, red teaming, or CTFs can be costly. Jumping into the rabbit hole of kernel exploits, pillaging or whatever time consuming attacks you fancy can potentially be avoided if one simply performs a careful assessment of the more immediate and actionable checks such as looking for any misconfigured file permissions first before other vectors to privilege escalation.
SUID 101
In a nutshell, the Set User ID (SUID) bit is a file permission in Linux that allows a user to run a file as the owner. For example, when the owner of the binary is root
and alice
runs the binary, it runs as though it’s executed by the root
user — not by alice
.
A file with the SUID bit set will have the character s
under the execute
position, as shown in the following example:
-rwsr-xr-x 1 root root 67K Apr 9 08:34 /usr/bin/find
What’s the implication?
Consider the low-privileged user alice
, who has limited control of the machine. alice
finds that /usr/bin/find
has the SUID bit set. What can alice
do then?
alice
simply needs to run the following:
find / -exec /bin/sh \; -quit
This command runs a shell as root
. With the root
shell, the user has full control of the machine. If alice
is a malicious actor or is controlled by a malicious actor, the entire machine can be fully compromised because of the SUID bit set on /usr/bin/find
.
Habits to build
One of the recent boxes at Hack The Box proved to be tricky, with one user saying, “I spent 2 hours to root,” and another claiming it could have taken “1 minute” to achieve privilege escalation—all because of a missed misconfigured SUID binary.
A key takeaway from that box is: whether you use linpeas
or manually run:
find / -user root -perm -4000 -exec ls -ldb {} \; 2>/dev/null
does not really matter if important details are missed. It’s generally a good practice to establish a systematic approach to learning and solving problems. Needless to say, this applies well to cybersecurity exercises—whether in pentesting, red teaming, or attacking a box, where the trade-offs between a lead over another can be costly.
Scenario
Let’s say you’re a red teamer or are attacking a box at your favorite CTF platform and came across the following:
When you’ve done enough tests in the past and came across lists after lists of SUID binaries, you’ll find that what stands out in that are the enlightenment
ones. The rest of the binaries are known to typically have their SUID bit set as they require escalated privileges to run.
A quick search on what this enlightenment
is will yield an associated CVE-2022-37706 that allows privilege escalation due to mishandling of /dev/..
. Here’s the link to the exploit for more details
Using the exploit, gives us the escalated privileges. So anything that stands out is worth the check, but missing that out altogether would mean a rabbit hole of all other vectors that can take time and energy.
Bottom line
There are several ways to approach a given machine and sometimes, no matter the preparation or experience, it may be inevitable to take the longer route only to find out the solution has been staring us in the face. Take comfort in that it simply signals the need to tweak our system and do better another time.