CVE-2021-3156 – Sudo Buffer Overflow (Linux)
Baron Samedit Privilege Escalation Exploit
📌 Overview
This project demonstrates the exploitation of CVE-2021-3156 (Baron Samedit), a critical heap-based buffer overflow vulnerability in the Linux sudo utility.
The vulnerability allows a low-privileged user to gain root access through improper argument handling in sudoedit.
🎯 Objectives
- Analyze vulnerability root cause
- Build a vulnerable Linux environment
- Execute public exploit code
- Achieve local privilege escalation
- Document Red Team attack workflow
🛠️ Lab Environment
| Component | Details |
|---|
| OS | Ubuntu 20.04 |
| RAM | 2 GB |
| CPU | 2 Cores |
| Virtualization | VirtualBox |
| Network | NAT |
⚠️ Vulnerability Details
- CVE ID: CVE-2021-3156
- Name: Baron Samedit
- Type: Heap Buffer Overflow
- Impact: Local Privilege Escalation
- Severity: Critical
This vulnerability affects the sudo program and enables attackers to execute arbitrary code with root privileges.
⚙️ Exploitation Process
- Verified vulnerable sudo version
- Installed required tools (gcc, git, make)
- Created low-privileged user
- Cloned exploit from GitHub
- Compiled exploit using GCC
- Executed exploit binary
- Gained root shell
💥 Result
Privilege escalation successfully achieved:
⚠️ Vulnerability Details
- CVE ID: CVE-2021-3156
- Affected Component: sudo
- Type: Heap-Based Buffer Overflow
- Impact: Privilege Escalation
🔐 Security Impact
- Full system compromise
- Arbitrary command execution
- Unauthorized access to sensitive files
- Persistent malware installation
🧪 Lab Environment
- Platform: VirtualBox
- OS: Ubuntu 20.04
- Tools:
🚀 Exploitation Steps (High-Level)
- Verify vulnerable sudo version
- Compile exploit code
- Execute exploit
- Gain root shell
⚠️ Detailed exploit steps are documented in the PDF report.
🛡️ Mitigation
- Update sudo to 1.9.5p2 or later
- Apply regular system patches
- Restrict sudo access
- Monitor privilege escalation attempts
📚 References
- MITRE CVE Database
- Exploit-DB
- GTFOBins
- PayloadsAllTheThings
⚡ Disclaimer
This project is created for educational purposes only.
All testing was conducted in a controlled lab environment.
Do not attempt this on systems without proper authorization.