
Containerised PoC and differential lab for CVE-2026-126170, an unauthenticated JSON injection (CWE-116) in the FortiManager/FortiAnalyzer JRPC API leading to command execution.
| CVE | CVE-2026-126170 |
| Component | Fortinet FortiManager and FortiAnalyzer — JSON-RPC (JRPC) API of the GUI component, POST /jsonrpc |
| Affected | FortiAnalyzer 8.0.0–8.0.2 and 7.6.0–7.6.7 · FortiAnalyzer Cloud 8.0.1–8.0.2 and 7.6.0–7.6.7 · FortiAnalyzer-BigData 7.6.0–7.6.2 · FortiManager 8.0.0–8.0.2 and 7.6.0–7.6.7 · FortiManager Cloud 8.0.1–8.0.2 and 7.6.0–7.6.7 · FortiSASE-Sovereign 25, 25.3, 25.4 and 26.2. FortiAnalyzer 7.2 and 7.4 and FortiManager 7.2 and 7.4 are not affected |
| Fixed in | 8.0.3, 7.6.8, FortiAnalyzer-BigData 7.6.3, FortiSASE-Sovereign 26.2 (migrate to a fixed release on 25, 25.3 and 25.4) |
| CWE | CWE-116 (Improper Encoding or Escaping of Output) |
| Impact | Unauthenticated remote code execution on the appliance, as the account the management daemon runs with, and injection into the appliance's own JSON response document |
| Vector | POST /jsonrpc on the management interface of the appliance, reachable without a session once the JSON API is enabled |
| Trigger | The value of a JSON-RPC parameter — the data members, the url, the session, the id — carried in a specially crafted HTTP request |
| Credit | Fortinet PSIRT (advisory FG-IR-26-219; the advisory records the discovery as internal, to the Fortinet Product Security team) |
Fortinet PSIRT advisory FG-IR-26-219 (published 2026-11-10) describes the flaw as a
JSON injection (CWE-116) in the JSON-RPC API of FortiManager and FortiAnalyzer and
rates it CVSS v3.1 9.8 CRITICAL, CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
The JSON API of the appliance translates a JSON-RPC document into a FortiOS-style
command line and into a JSON response document. The handler places the values of the
request into both generated outputs without encoding them for the destination they
enter, so a value that contains a double quote terminates the quoted argument of the
generated command line — the remainder of the value is then parsed as shell syntax by
the command sink — and the same value becomes a structural part of the response
document, where an injected "key":"value" sequence is a real key of the parsed
response. The API is reachable over the network without authentication (PR:N) and
without user interaction (UI:N), and the exposure condition is a configuration
decision: the JSON API is disabled by default and has to be enabled on the
appliance before the flaw is reachable.
This repository contains a containerised laboratory that reproduces the flaw, the differential against the patched build and against the two published mitigation states, and the results of a full sibling-path sweep.
FortiManager and FortiAnalyzer are proprietary appliances. No Fortinet code, binary or configuration is redistributed here, and the vendor does not publish the JRPC handler's source. What is reproducible here is therefore:
rpc-permit none
workaround — taken verbatim from FG-IR-26-219;POST /jsonrpc, Content-Type: application/json, a JSON-RPC 2.0 document of the shape
{"id":<int>,"method":"<get|set|add|delete|exec>","params":[{"url":"<api path>","data":{...}}],"session":"<session id>"};Everything the laboratory asserts about the vendor product is sourced from the advisory; everything it asserts about 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 target component alone.
The model lives in lab/fmgr_jrpc.py and is selected with FMGR_MODE:
FMGR_MODE | model | behaviour | version reported |
|---|---|---|---|
vuln | FortiManager 7.6.7 | the value is concatenated into the command line and into the response document verbatim; the command line is executed through /bin/sh -c | 7.6.7 |
fixed | FortiManager 7.6.8 | the value is shell-quoted for the command line and JSON-escaped for the response document; the command is executed without a shell | 7.6.8 |
fixed-rpc-none | published workaround | set rpc-permit none: the JSON API is disabled, the endpoint refuses every request with HTTP 403 | 7.6.8 |
api-disabled | operational form of the workaround | the JSON API was never enabled: the endpoint is not present, the request never reaches a handler | 7.6.8 |
Two modelling decisions are stated explicitly, because they are assumptions and not facts about the vendor product:
session is dispatched in both builds; a session that is present but
unknown is refused by the patched build before the dispatch and is only noticed
after the command has run in the vulnerable build — that ordering is itself part
of the modelled defect and is exercised by the matrix.fixed-rpc-none and api-disabled
models are the two states a real appliance is in when the JSON API has not been
enabled, or when it has been disabled again with the published workaround.CWE-116 is an output defect. The handler of the JRPC API takes values out of the request and writes them into two generated outputs — the command line and the response document — and it writes them without encoding them for the destination they enter.
The handler recovers the members of the request from the raw request text
(lab/fmgr_jrpc.py:158):
def _scan_value(s, i):
"""Recover the value that starts at s[i].
Returns (value, vstart, vend). For a string the JSON escapes of the request
are interpreted; for every other token the literal text of the request is
returned.
"""
The recovery interprets the request's own JSON escapes — a \" on the wire becomes a
literal double quote in the recovered value — and truncates the value at the first
NUL byte. It performs no encoding for the destination the value is about to enter.
The request is translated into FortiOS-style command segments
(lab/fmgr_jrpc.py:262) and rendered (lab/fmgr_jrpc.py:305):
def render(segs, encoded):
out = []
for seg in segs:
if seg[0] == "lit":
out.append(seg[1])
elif encoded:
out.append(shlex.quote(seg[1])) # 7.6.8: quoted for the shell
else:
out.append('"%s"' % seg[1]) # 7.6.7: dropped in verbatim
return "".join(out)
The vulnerable rendering puts the recovered value inside double quotes without
escaping it. A value that contains a double quote therefore terminates the quoted
argument, and everything after it is parsed as shell syntax by the sink. For a set
on /api/v2/cmdb/system/admin the generated command line of the vulnerable build is:
config system admin
set "description" "A","jrpc_injected_b8213c1c7950aa46":"b8213c1c7950aa46`id > /results/marker/jrpc-b8213c1c7950aa46.txt; echo b8213c1c7950aa46 >> /results/marker/jrpc-b8213c1c7950aa46.txt`"
end