FortiMail HA Join-Request OS Command Injection (CVE-2026-126148 / FG-IR-26-200)
Published: 2026-11-25 • Researcher: Lê Hiếu (GitHub: googlesky) — PoC and laboratory; Fortinet PSIRT — FG-IR-26-200 advisory (no individual reporter named)
- Severity
- Critical
- CVE
- CVE-2026-126148
- Category
- network
- Affected product
- Fortinet FortiMail — high-availability cluster join-request handler
- Affected versions
- FortiMail 8.0.0 through 8.0.1; FortiMail 7.6.0 through 7.6.6 (fixed in 8.0.2 and 7.6.7)
- 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-200 advisory (no individual reporter named) |
| CVE / Advisory | CVE-2026-126148 |
| Category | network |
| Severity | Critical |
| CVSS Score | 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H, vector as published by the upstream write-up) |
| Status | PoC |
| Tags | RCE, command-injection, FortiMail, Fortinet, HA-cluster, unauthenticated, CWE-78, TCP, UDP, appliance |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Fortinet FortiMail — high-availability cluster join-request handler |
| Versions Affected | FortiMail 8.0.0 through 8.0.1; FortiMail 7.6.0 through 7.6.6 (fixed in 8.0.2 and 7.6.7) |
| Language / Platform | Proprietary FortiMail appliance firmware (Linux-based); PoC written in Python 3, executed in Podman containers |
| Authentication Required | No |
| Network Access Required | Yes — reachability to the FortiMail HA port range (20000–20005, 20010–20014), join listener on UDP/TCP 20005 |
Summary
Fortinet FortiMail builds a cluster-management command line from the peer-identity fields of an incoming HA join request, and in releases 8.0.0 through 8.0.1 and 7.6.0 through 7.6.6 that command line reaches a shell, so a crafted join packet yields OS command injection as the FortiMail daemon. The vendor advisory FG-IR-26-200 rates the flaw 9.8 and states that an unauthenticated remote attacker may execute unauthorized code or commands; the upstream write-up places the cluster-digest check after the peer-registration command, which is what keeps the attack unauthenticated. This entry archives a containerised laboratory that reproduces the flaw in a Python model of the HA daemon, with a vulnerable 8.0.1 arm, a patched 8.0.2 arm and a hypothetical partial-remediation arm. The PoC never touches a real appliance: it speaks a modelled packet format against the model, so the entry documents the vulnerability class and the remediation shape rather than providing a turnkey exploit for FortiMail hardware.
Vulnerability Details
Root Cause
The HA join request is necessarily accepted from a peer the daemon has never seen, so its peer-identity fields (cluster-id, serial, hostname, peer-ip) are untrusted by construction. In the modelled FortiMail 8.0.1 handler the fields are substituted into a command template with no quoting and no character-set validation, the argv is joined back into a single string, and that string is executed through /bin/sh -c. A metacharacter in any interpolated field therefore becomes shell syntax rather than data. The second half of the root cause is ordering: the packet’s cluster digest is compared only after the peer-registration command has already run, so a packet with a wrong digest is still acted upon and the reply merely records that the peer is not trusted.
Attack Vector
An unauthenticated attacker who can reach the HA ports sends a crafted join-request packet (modelled as magic FMLHA, version 0x01, message type 0x01, then five length-prefixed fields) over UDP or TCP with a shell fragment in hostname, peer-ip, cluster-id or serial. The daemon assembles the fml_ha peer add command line, executes it through the shell, and the injected fragment runs as the daemon user. The same dispatcher serves the sibling HA roles, so group-mode ports 20010–20014 and the sync roles on 20001–20004 expose the same sink in the model. A minimal injected value is x; id > /results/marker/token.txt, with command substitution, ${IFS}, newline and CRLF forms also accepted by the vulnerable arm.
Impact
Remote code execution as the FortiMail service account, which the laboratory runs as uid 0 inside its container, mirroring the privileged service account on an appliance. The PoC proves execution by writing a marker containing uid=0(root) and a per-run random token, and the daemon command log shows the injected text inside the executed line. On a real appliance this would mean full control of the mail gateway, including configuration, mail stores and any credentials or trust material the daemon can read.
Environment / Lab Setup
OS: Linux x86_64 host with Podman (rootless or rootful); containers bounded at 2 CPUs / 4 GB
Target: localhost/cve-2026-126148:vuln (the three HA models: FML_MODE=vuln, fixed, fixed-partial)
Attacker: localhost/cve-2026-126148-poc:local (python:3.12-alpine, standard library only)
Network: Podman network cve126148lab; join listener fortimail-ha-vuln:20005
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 starts the vulnerable 8.0.1 model on 20005, the patched 8.0.2 model and the partial-remediation model, all from one image and differing only in FML_MODE.
- Confirm the target is a vulnerable model — make check-vuln sends a benign join request and then join requests with an injected hostname, an injected peer-ip and an injected hostname over UDP; executed slots and the marker content are printed.
- Run the full chain — make exploit-vuln (or python3 exploit/exploit.py –target fortimail-ha-vuln:20005) tries both injection slots over TCP and UDP and reads the shared /results volume.
- Verify root execution and attribution — the marker must contain both uid=0(root) and the per-run token; the daemon command log line must show the injection inside the command that exec=shell ran.
- Differential against the patched shape — make check-fixed and make exploit-fixed run the same packets against the 8.0.2 model, which validates every interpolated field with a full match on [A-Za-z0-9._-] and executes an argument vector with no shell.
Exploit Code
See
exploit.py(standalone full-chain exploit) andpoc.py(the same PoC with the check/probe/mitigation/0day modes). The modelled daemon is infortimail_ha.py; the command-construction sink isexecute()at line 335, with the unvalidated token substitution inbuild_argv()at line 319 and the shell exec in the same function.
The packet builder and the canonical payload are small:
| |
TCP framing is a 4-byte big-endian length prefix followed by the packet; UDP is one datagram per packet. The default mode of exploit.py is exploit, and exit code 1 means the injected command executed.
Expected Output
$ make exploit-vuln
{
"summary": {
"mode": "exploit",
"target": "fortimail-ha-vuln:20005",
"marker_present": true,
"marker_content": "uid=0(root) gid=0(root) groups=0(root)\ntoken=a693085aae05692c",
"confirmed": ["hostname:tcp", "hostname:udp", "peer-ip:tcp", "peer-ip:udp"],
"uid_root_confirmed": true,
"impact": "unauthenticated remote command execution as uid=0(root) in the FortiMail HA daemon, through the cluster join-request listener"
},
"exit_code": 1
}The patched model answers the same packets with no confirmed slot and exit code 0; the full captures are in exploit-vulnerable-run.txt, check-vulnerable-run.txt and check-fixed-run.txt.
Detection & Indicators of Compromise
- Inbound traffic to FortiMail HA ports 20000–20005 and 20010–20014 from outside the cluster segment, especially join-request-sized packets to 20005 or 20010–20014.
- FortiMail HA / event logs showing peer-registration activity for peers whose hostname, serial or IP was never provisioned, or peer entries with unexpected characters.
- Join requests answered as “peer not trusted (cluster digest mismatch)” while a peer-registration command still ran — in the model this is the signature of the digest check happening after the sink.
- Shell metacharacters or command substitution syntax in peer-identity fields, in any HA packet capture or daemon command log line.
- Unexpected marker or output files, or child processes of the HA daemon (fml_ha) spawning a shell.
Example (suricata-style):
| |
The second rule is deliberately broad and will need tuning to the fields the deployed firmware actually exposes.
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade to FortiMail 8.0.2 (8.0 branch) or FortiMail 7.6.7 (7.6 branch), per FG-IR-26-200. |
| Workaround | Fortinet publishes no workaround and no virtual patch for FG-IR-26-200. The mitigation that takes effect is network isolation: keep the HA port range 20000–20005 and 20010–20014 off untrusted segments and allow it only between cluster members. |
| Config Hardening | Restrict HA ports with host firewalls and upstream ACLs, segment cluster traffic on a dedicated network, verify cluster digests before any peer state change in custom integrations, and alert on peer registration by unknown peers. |
References
Notes
Auto-ingested from https://github.com/googlesky/CVE-2026-126148 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 command execution and confirms it from outside the container, so it is not a detector, scanner or audit tool. However, FortiMail is proprietary: the lab is a Python model of the HA daemon (fortimail_ha.py) built from the vendor’s advisory, and the packet format, port map and command template are explicitly modelled, not reverse-engineered from firmware. Nothing here will attack a real FortiMail appliance, and the README’s own scope section says so. Status is therefore PoC rather than Weaponized: the exploitation is real against the model, but it is not a weapon against the vendor product.
License: MIT (Copyright (c) 2026 Lê Hiếu). The upstream README, SECURITY.md and LICENSE state the model-only scope; the archived files are attributed to the upstream author via the repository URL and the LICENSE is not copied here (only source and evidence text files were archived). The evidence files are the upstream captured runs from 2026-11-12, not executions performed during ingestion; no exploit code was run and no container was started.
Limitations and caveats: the modelled protocol is not the vendor’s wire format, so packet captures from this lab have no direct detection value beyond the class of traffic; the uid=0(root) proof reflects the container’s daemon 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 upstream 0day sweep reports 0 of 129 injections on the fixed model but a residual unauthenticated peer addition on the patched line (digest compared after peer registration) — that residual is a property of the model’s ordering and FG-IR-26-200 does not say where the real daemon compares the digest. The 99 KB sweep log, ha-events.jsonl and ha-helper-argv.jsonl were not copied; the command log and the run captures that support the entry’s claims were. Run only against systems you own or have written authorization to test.
| |