Day 10: Advanced Privilege Escalation & Security Audits 🕵️♂️
Source: Dev.to
Audit Overview
Day 10 of my #1HourADayJourney focused on breaking things to understand how they’re built. To secure a system, you have to think like an attacker. Below are the key findings from the audit.
SUID (Set User ID) Vulnerability
- What it does: Allows a program to run with the privileges of the file owner.
- The vulnerability: If a binary is owned by
rootand has thesbit set, it runs asroot. If the binary is a shell, you obtain a root shell. - Lesson: Always check for binaries with the
spermission during system audits.
Dangerous Script Pattern
- Scenario: A script owned by
rootis executable by a group you belong to, or writable by you. - Exploit: You can inject a payload into the script, wait for the cron daemon to trigger it as
root, and spawn a privileged shell (/bin/bash -p). - Example: If a cron job calls
backup.shinstead of/usr/local/bin/backup.sh, the system searches the$PATH. Controlling a directory earlier in the path lets you place your ownbackup.shthere.
Best Practices
- Use absolute paths in cron jobs and configuration files to avoid path hijacking.
- Treat security as a chain: A single weak link—such as a writable script in a cron job—can compromise the entire system.
Follow my journey: #1HourADayJourney