Overview
Baron Samedit (CVE-2021-3156) is a serious heap-based buffer overflow in the Unix sudo program. When exploited, it allows unprivileged users to escalate privileges to root by triggering unsafe handling of command-line arguments.
Technical Description
The flaw resides in how sudo parses command line arguments, specifically when the "-s" or "-i" flags are used without a command. The vulnerable code fails to properly sanitize user input, resulting in a heap overflow condition.
Exploitation Steps
- Run a crafted sudo command using "-s" or "-i" options.
- Trigger the overflow by passing a long input that overflows internal buffers.
- Execute shellcode or manipulate memory to gain root privileges.
Indicators of Compromise (IOCs)
- Unexpected use of sudo by non-privileged users.
- Presence of exploit scripts targeting sudo.
- Audit logs showing sudo commands with "-s" or "-i" and long arguments.
Mitigation
- Upgrade sudo to version 1.9.5p2 or later.
- Restrict sudo access to only trusted users.
- Use AppArmor or SELinux to restrict execution behavior.
MITRE ATT&CK Techniques
- T1068 - Exploitation for Privilege Escalation
- T1548.003 - Abuse Elevation Control Mechanism: Sudo and Sudo Caching
View this mapping using official
MITRE ATT&CK Navigator