Share
## https://sploitus.com/exploit?id=5FCD7A2B-A555-57AB-BB70-B7AED25B5955
# 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

1. Verified vulnerable sudo version  
2. Installed required tools (gcc, git, make)  
3. Created low-privileged user  
4. Cloned exploit from GitHub  
5. Compiled exploit using GCC  
6. Executed exploit binary  
7. Gained root shell  

---

## ๐Ÿ’ฅ Result

Privilege escalation successfully achieved:

```bash
whoami
root
```
---

## โš ๏ธ 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:**  
  - Git  
  - GCC  
  - Linux Terminal  

---

## ๐Ÿš€ Exploitation Steps (High-Level)
1. Verify vulnerable sudo version  
2. Compile exploit code  
3. Execute exploit  
4. 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.

---