FortiMail Management Interface Path Traversal to Root Command Execution (CVE-2026-126147 / FG-IR-26-199)
Published: 2026-11-25 • Researcher: Lê Hiếu (GitHub: googlesky) — PoC and laboratory; Fortinet PSIRT — FG-IR-26-199 advisory (no individual reporter named)
- Severity
- Critical
- CVE
- CVE-2026-126147
- Category
- network
- Affected product
- Fortinet FortiMail — management interface API
- Affected versions
- FortiMail 8.0.0 through 8.0.1; FortiMail 7.6.0 through 7.6.6; FortiMail 7.4.0 through 7.4.8; FortiMail 7.2 all versions (fixed in 8.0.2, 7.6.7 and 7.4.9; 7.2 is unfixed)
- Disclosed
- 2026-11-25
- Patch status
- Unverified
Tags
References
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-25 |
| Last Updated | 2026-11-19 |
| Author / Researcher | Lê Hiếu (GitHub: googlesky) — PoC and laboratory; Fortinet PSIRT — FG-IR-26-199 advisory (no individual reporter named) |
| CVE / Advisory | CVE-2026-126147 |
| Category | network |
| Severity | Critical |
| CVSS Score | 9.8 (CVSS v3.1 base score; the upstream README quotes AV:N/AC:L/PR:N/UI:N, the full vector is not given in the worklist or NVD extract) |
| Status | PoC |
| Tags | path-traversal, arbitrary-file-write, RCE, FortiMail, Fortinet, unauthenticated, CWE-22, management-interface, appliance, lab-model |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Fortinet FortiMail — management interface API |
| Versions Affected | FortiMail 8.0.0 through 8.0.1; FortiMail 7.6.0 through 7.6.6; FortiMail 7.4.0 through 7.4.8; FortiMail 7.2 all versions (fixed in 8.0.2, 7.6.7 and 7.4.9; 7.2 is unfixed) |
| Language / Platform | Proprietary FortiMail appliance firmware (Linux-based); the lab model and PoC are Python 3, run in Podman containers |
| Authentication Required | No |
| Network Access Required | Yes — reachability to the FortiMail management interface (HTTPS/443 in the model) |
Summary
CVE-2026-126147 is a path traversal (CWE-22) in the FortiMail management interface API: a caller-supplied path component is joined to a restricted data directory with no normalisation and no containment check, so an unauthenticated request can write a file outside that directory. Because the appliance executes scripts that land in its maintenance script directory, the arbitrary write becomes command execution as the appliance service account, which the laboratory models as root. Fortinet’s advisory FG-IR-26-199 rates the flaw 9.8 and lists FortiMail 8.0.0 through 8.0.1, 7.6.0 through 7.6.6, 7.4.0 through 7.4.8 and all of 7.2 as affected. The archived repository is a containerised reproduction: a Python model of the management interface with vulnerable, patched and partial-remediation modes, plus a PoC that proves both the write outside the root and the execution marker.
Vulnerability Details
Root Cause
The vulnerable model appends the caller-supplied name to the restricted data directory with os.path.join and hands the result to the file system. That is a string operation: it does not resolve dot-dot segments, it does not reject an absolute second component, and it does not check that the joined path still lies inside the directory it was supposed to stay in, so a name such as ../exec/pwn.sh escapes the root. The model reproduces three properties the repository attributes to the appliance: the path is percent-decoded a second time, the path handling truncates at a NUL byte the way a C implementation does, and the restricted directory contains a linked data directory (shared-link) that points at the appliance script directory, which yields an execution primitive without any dot-dot sequence. The patched model resolves the joined path with realpath and then requires containment, which collapses dot-dot segments and resolves symlinks before the comparison; a hurried fix that only compares the un-normalised joined string against the root with a prefix test still lets the traversal through. Everything here describes the model’s path handling; the vendor advisory states only the class of defect (improper limitation of a pathname to a restricted directory in the FortiMail API) and does not publish the affected endpoint.
Attack Vector
An unauthenticated attacker sends a management-interface request whose path or filename field carries a traversal sequence. The full chain uses a single JSON POST to the modelled attachment upload endpoint with a filename of ../exec/pwn_TOKEN.sh and a base64 content field holding a shell script; the appliance writes the script into its script directory and the maintenance task runner executes it. The sweep in the repository exercises four modelled endpoints (attachment upload, configuration import with a multipart filename part, IBE key store, and attachment download), twelve payload shapes (plain and encoded dot-dot, absolute paths, NUL truncation, prefix bypass, symlinked data directory, backslash separators, and others) and both the write and read directions. The advisory rates the vector AV:N/AC:L/PR:N/UI:N, so the request is processed before any authentication decision.
Impact
Arbitrary file write outside the restricted data directory, escalating to command execution as the appliance service account (uid 0 in the laboratory container, mirroring the privileged appliance daemon). The PoC proves execution by writing a per-run marker containing uid=0(root), a random token and the string PWNED to a shared volume, so the marker can be attributed to the request that produced it. On a real appliance this would mean control of the mail gateway: configuration, mail stores, and any credential or trust material readable by the service account. The read direction of the same flaw is an arbitrary file disclosure primitive on its own, which is why the fix has to cover reads as well as writes.
Environment / Lab Setup
OS: Linux x86_64 host with Podman (rootless or rootful); containers bounded at 2 CPUs / 4 GB
Target: localhost/cve-2026-126147:vuln (three models of the management interface:
FML_MODE=vuln (8.0.1), fixed (8.0.2), fixed-partial (prefix-test remediation shape))
Attacker: localhost/cve-2026-126147-poc:local (python:3.12-alpine, standard library only)
Network: Podman network cve126147lab; HTTPS listener fortimail-vuln:443 (self-signed certificate)
Tools: podman, make, bash, python3 (no third-party packages)Setup Steps
| |
The driver script run-lab.sh exposes the same targets: ./run-lab.sh up|check|exploit|probe|mitigation|0day|differential|evidence|down. The standalone exploit can also be run directly with python3 exploit/exploit.py, which forces the exploit mode.
Proof of Concept
Step-by-Step Reproduction
- Build and start the lab — make prepare && make up builds one appliance image and runs it three times with FML_MODE set to vuln, fixed and fixed-partial; all three share the same code path, configuration, entrypoint and TLS listener, and differ only in the path handling.
- Classify without side effects — make check-vuln performs one benign write inside the restricted directory and then a read traversal of a file that lives outside it, so the classification leaves no artefact behind. The vulnerable model returns the outside secret with HTTP 200; the patched model returns 403.
- Run the full chain — make exploit-vuln (or python3 exploit/exploit.py) generates a random token, POSTs a JSON body whose filename is ../exec/pwn_TOKEN.sh and whose content is a base64 shell script, and waits for the execution marker on the shared results volume.
- Verify root execution and attribution — the marker must contain uid=0(root), the per-run token and PWNED; the appliance execution log must show the task runner executing the resolved script path. The exploit exits 1 on success, 0 when the write is refused, and 3 when the file was stored but no marker appeared.
- Negative controls — make exploit-fixed runs the same chain against the 8.0.2 model and gets HTTP 403 path outside the restricted directory. make 0day sweeps twelve payload shapes against all four endpoints on the patched line and reports zero escapes; make differential shows that the fixed-partial prefix-test shape still escapes and executes.
Exploit Code
See exploit.py (standalone full-chain exploit) and poc.py (the same PoC with check/probe/mitigation/0day modes). The modelled management interface is in fortimail_web.py; resolve_write() starts at line 131 (the vulnerable join is at line 145, the resolved-path containment fix at line 158), and the execution sink run_if_executed() is at line 219.
The write primitive is one JSON request:
| |
Expected Output
| |
The patched model answers the same request with HTTP 403 and the error path outside the restricted directory; those captures are in exploit-vulnerable-run.txt, exploit-fixed-run.txt, check-vulnerable-run.txt, check-fixed-run.txt and differential-table.txt.
Detection & Indicators of Compromise
- Management-interface requests whose filename, name or path field contains dot-dot segments, percent-encoded or double-encoded dot-dot, a NUL byte, an absolute path, or the name of the linked data directory. In the model these arrive as POST to the attachment upload, configuration import or IBE key endpoints, or as GET on the attachment download endpoint; the real endpoint names are not published by the advisory, so treat this as a class-level signature rather than a product rule.
- HTTP 200 responses to a write whose stored path is reported outside the restricted directory, or the appliance error string path outside the restricted directory on a patched build (a 403 for such a request is the expected, benign outcome).
- Appliance task-runner or maintenance execution log entries for scripts in the script directory that were not deployed by an administrator, and shell child processes of the management daemon.
- Unexpected files in the appliance script directory or the directory that links to it, especially short shell scripts writing output to shared or world-readable paths, and marker files containing a random token.
- Access-log lines showing a traversal download of a file that lives next to, not inside, the data directory (the check mode reads such a file with HTTP 200 on the vulnerable model).
Example access-log pattern from the model:
| |
SIEM / IDS rule (example):
| |
The rule is deliberately broad and matches the modelled request shape only; tune it to the endpoints and parameter names the deployed firmware actually exposes.
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade to FortiMail 8.0.2 (8.0 branch), 7.6.7 (7.6 branch) or 7.4.9 (7.4 branch). FortiMail 7.2 is unfixed, so migrate to a fixed branch. FortiMail Cloud was remediated by Fortinet on 2026-10-05 by moving the firmware to 7.6.7 GA / 8.0.2 GA. |
| Workaround | FG-IR-26-199 publishes no workaround and no virtual patch. The mitigation that takes effect is reachability: keep the management interface off untrusted networks and allow it only from a management VLAN or VPN. The usual request filter that rejects a body containing dot-dot-slash is not a substitute; the upstream sweep shows it blocks 7 of 12 payload shapes and lets the encoded, absolute-path, symlink and backslash forms through. |
| Config Hardening | Restrict management access with host firewalls and upstream ACLs, disable management features and endpoints that are not in use (attachment store, configuration import, IBE key store), avoid symlinked data directories inside the restricted root, and alert on writes that resolve outside it. Fixes must resolve the path (realpath) and compare resolved paths, not string prefixes, and must cover the read direction as well as the write direction. |
References
Notes
Auto-ingested from https://github.com/googlesky/CVE-2026-126147 on 2026-11-25.
Review verdict: a real PoC with exploit code, ingested with limitations. The repository ships working exploit code (exploit.py, poc.py) that triggers a traversal write outside the restricted directory and confirms command execution from outside the container by reading the marker the executed script wrote, so it is not a detector, scanner or audit tool. However, FortiMail is proprietary: the lab is a Python model of the management interface (fortimail_web.py) built from the vendor’s advisory and the POSIX semantics of path resolution, and the endpoint list, path handling, script directory and task runner are explicitly modelled, not reverse-engineered from firmware. Nothing here will attack a real FortiMail appliance, and the upstream README says so in its scope section. Status is therefore PoC rather than Weaponized: the exploitation is real against the model, but it is not a weapon against the vendor product. The advisory does not name the affected endpoint, so the repository establishes that the class is exploitable as described and that a resolved-path containment check closes it, not which FortiMail URL carries the flaw.
License: MIT (Copyright (c) 2026 Lê Hiếu), archived as LICENSE alongside the upstream README. The archived files are attributed to the upstream author via the repository URL. The evidence files are the upstream captured runs from 2026-11-12, not executions performed during ingestion; no exploit code was run, no container was started and no script was executed while building this entry.
Limitations and caveats: the modelled endpoint names and payload handling are not the vendor’s wire format, so packet captures and log lines from this lab have detection value at the level of the vulnerability class only; the uid=0(root) proof reflects the container’s service user, not a claim about the appliance’s privilege model; the third arm (fixed-partial) is a hypothetical remediation shape and carries no assertion about what Fortinet shipped; the read-direction secret used by the check mode is a laboratory file. Not copied: the large 0day sweep logs (0day-sweep*.txt), the server access and write logs, and the fixed-partial and mitigation run captures. The files that support the entry’s central claims (exploit and check runs, the three-way differential, the execution log, the lab sources and build files) are included. Run only against systems you own or have written authorization to test.
| |