Cisco ATA — 1 vulnerability check

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

← All products · Feeds on GitHub

Cisco ATA 187 unauthenticated OS command access on TCP 7870

CVECVE-2013-1111
Severitycritical · CVSS 9.0
Categoryrce — Remote code execution
Servicesrbt-smc, telnet, unknown
Detectionset_var, script, tcp_open, tcp_send, sleep, tcp_close, match · highest QoD 97
Feedtests/vulnerabilities/cisco-ata/CVE-2013-1111.yaml

Cisco ATA 187 Analog Telephone Adaptors running firmware 9.2.1.0 or 9.2.3.1 before ES build 4 accept sessions on TCP port 7870 without any authentication and run the operating-system commands they receive (CVE-2013-1111). The check opens a session on the port, declines the Telnet options the device proposes, and, when no login or password prompt follows, sends one command line that echoes the sum of two random numbers and runs `id`. It reports the flaw when the reply holds the computed sum, which never appears in the request (or, for a minimal shell without arithmetic, the uid/gid output of `id`). Only `echo` and `id` run on the device. Any other service that gives a password-less shell is reported the same way, since it is just as critical.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Opens a persistent TCP/TLS socket
  3. Parses / computes the next value with a Rhai script
  4. Sends a binary frame on the open socket
  5. Sends … on the open socket
  6. Parses / computes the next value with a Rhai script
  7. Parses / computes the next value with a Rhai script
  8. Sends a binary frame on the open socket
  9. Sends … on the open socket
  10. Parses / computes the next value with a Rhai script
  11. Sends … on the open socket
  12. Parses / computes the next value with a Rhai script
  13. Parses / computes the next value with a Rhai script
  14. Parses / computes the next value with a Rhai script
  15. … and 2 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/cisco-ata/CVE-2013-1111.yaml
# Cisco ATA 187 Analog Telephone Adaptor — unauthenticated OS shell on TCP 7870
# (CVE-2013-1111, Cisco bug CSCtz67038, cisco-sa-20130206-ata187).
#
# Firmware 9.2.1.0 and 9.2.3.1 before ES build 4 do not enforce access control
# on a Telnet-style service on TCP 7870: anyone who connects can run operating
# system commands on the adaptor without logging in.
#
# Ported from OpenVAS/Greenbone NVT 2016/gb_cisco_ata_187_57782.nasl
# (OID 1.3.6.1.4.1.25623.1.0.140086, GPL-2.0-only): connect to 7870, answer the
# Telnet negotiation, send `id` and report a `uid=<n>...gid=<n>` reply.
#
# Detection:
#   QoD 97 — the command line `echo NOCTIS$((a+b))Z;id` (two random numbers)
#            makes the shell print NOCTIS<a+b>Z. The sum never appears in what
#            we send, so an echo service or a login prompt cannot produce it.
#   QoD 75 — only the NASL's evidence: the `id` output (uid=<n>...gid=<n>), for
#            a minimal shell without arithmetic expansion. "uid=" is never in
#            what we send either.
#
# Better than the NASL (stated in the PR):
#   - in-band arithmetic proof instead of only matching `id` output;
#   - the Telnet options the device proposes are refused (WONT/DONT) before
#     the command, so a shell that waits for the negotiation is still reached;
#   - output that arrives after the first read (slow device) is read again;
#   - a service that shows a login / password prompt, at once or after the
#     options are answered, is not sent the command (no stray failed login on
#     ordinary Telnet servers);
#   - runs on the matched port, not only on a hard-coded 7870: nmap names 7870
#     "rbt-smc" from its port table, or "telnet" / "unknown" after version
#     detection. Any password-less shell found this way is reported: the
#     finding title says "unauthenticated OS command execution" first and
#     names the Cisco port/CVE as the likely cause, and the text says that on
#     another device it is an equally critical open shell.
#
# Nothing is changed on the adaptor: only `echo` and `id` run.
# category: rce (OS command execution) + `intrusive` so scans can exclude it.
uid: 05f1770a-5346-4f7b-b815-8bd77b77e026
name: "Cisco ATA 187 unauthenticated OS command access on TCP 7870 (CVE-2013-1111)"
description: |
  Cisco ATA 187 Analog Telephone Adaptors running firmware 9.2.1.0 or 9.2.3.1
  before ES build 4 accept sessions on TCP port 7870 without any
  authentication and run the operating-system commands they receive
  (CVE-2013-1111). The check opens a session on the port, declines the Telnet
  options the device proposes, and, when no login or password prompt follows,
  sends one command line that echoes the sum
  of two random numbers and runs `id`. It reports the flaw when the reply holds
  the computed sum, which never appears in the request (or, for a minimal shell
  without arithmetic, the uid/gid output of `id`). Only `echo` and `id` run on
  the device. Any other service that gives a password-less shell is reported
  the same way, since it is just as critical.
cves: [CVE-2013-1111]
cvss: 9.0
severity: critical
category: rce
confidence_base: 0.20
tags: [cisco, ata, ata-187, voip, telnet, backdoor, unauthenticated, rce, intrusive]
services: [rbt-smc, telnet, unknown]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2013-1111"
  - "https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20130206-ata187"
  - "https://www.securityfocus.com/bid/57782"

steps:
  # ---------------------------------------------------------------- set-up
  - id: init-gate
    action: set_var
    var_name: gate
    var_value: false

  - id: init-proof
    action: set_var
    var_name: proof_ok
    var_value: false

  - id: init-id
    action: set_var
    var_name: id_ok
    var_value: false

  - id: init-out
    action: set_var
    var_name: tn_out
    var_value: ""

  - id: init-cmd
    action: set_var
    var_name: r_cmd
    var_value: {response: ""}

  - id: init-tail
    action: set_var
    var_name: r_tail
    var_value: {response: ""}

  - id: init-neg
    action: set_var
    var_name: r_neg
    var_value: {response: "", response_hex: ""}

  - id: init-neg-late
    action: set_var
    var_name: r_neg_late
    var_value: {response: "", response_hex: ""}

  - id: init-late
    action: set_var
    var_name: r_late
    var_value: {response: ""}

  # The command line and the marker the shell must print for it.
  - id: build-marker
    action: script
    store_as: mk
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{
        cmd: "echo NOCTIS$((" + a + "+" + b + "))Z;id",
        marker: "NOCTIS" + (a + b) + "Z"
      }

  # ----------------------------------------------------------- the session
  - id: open
    action: tcp_open
    handle: tn
    port: "{{port}}"
    read_banner: true
    timeout_secs: 10
    store_as: conn

  # Refuse every option the server proposed (DO x -> WONT x, WILL x -> DONT x).
  - id: refuse-1
    action: script
    condition: "conn.connected == true"
    store_as: neg1
    code: |
      let h = if type_of(conn.banner_hex) == "string" { conn.banner_hex } else { "" };
      let out = "";
      let i = 0;
      let n = strlen(h);
      while i + 1 < n {
        if substr(h, i, i + 1) == "ff" && i + 5 < n {
          let c = substr(h, i + 2, i + 3);
          let o = substr(h, i + 4, i + 5);
          if c == "fd" { out += "fffc" + o; i += 6; continue; }
          if c == "fb" { out += "fffe" + o; i += 6; continue; }
          if c == "fc" || c == "fe" { i += 6; continue; }
        }
        i += 2;
      }
      #{ hex: out }

  # A standard telnetd shows "login:" only once its options are answered:
  # answer them first, on their own, and read what comes next.
  - id: answer-1
    action: tcp_send
    handle: tn
    condition: "conn.connected == true && neg1.hex != \"\""
    send_hex: "{{neg1.hex}}"
    timeout_secs: 5
    store_as: r_neg

  - id: answer-wait
    action: sleep
    condition: "conn.connected == true && neg1.hex != \"\""
    duration_ms: 1000

  - id: answer-late
    action: tcp_send
    handle: tn
    condition: "conn.connected == true && neg1.hex != \"\""
    send: ""
    timeout_secs: 5
    store_as: r_neg_late

  # Skip services that ask for a login (no unauthenticated shell, and the
  # command would only count as a failed login).
  - id: gate-check
    action: script
    condition: "conn.connected == true"
    store_as: gate
    code: |
      let g = "";
      if type_of(conn.banner) == "string" { g += conn.banner + "\n"; }
      for r in [r_neg, r_neg_late] {
        if type_of(r.response) == "string" { g += r.response + "\n"; }
      }
      g = tolower(g);
      strstr(g, "login:") == "" && strstr(g, "password") == "" && strstr(g, "username") == ""

  # Refuse any further options (second negotiation round) and append the
  # command line, in a single frame.
  - id: build-frame
    action: script
    condition: "gate == true"
    store_as: fr
    code: |
      let h = "";
      for r in [r_neg, r_neg_late] {
        if type_of(r.response_hex) == "string" { h += r.response_hex; }
      }
      let out = "";
      let i = 0;
      let n = strlen(h);
      while i + 1 < n {
        if substr(h, i, i + 1) == "ff" && i + 5 < n {
          let c = substr(h, i + 2, i + 3);
          let o = substr(h, i + 4, i + 5);
          if c == "fd" { out += "fffc" + o; i += 6; continue; }
          if c == "fb" { out += "fffe" + o; i += 6; continue; }
          if c == "fc" || c == "fe" { i += 6; continue; }
        }
        i += 2;
      }
      #{ hex: out + hexstr(mk.cmd + "\n") }

  - id: send-cmd
    action: tcp_send
    handle: tn
    condition: "gate == true"
    send_hex: "{{fr.hex}}"
    timeout_secs: 10
    store_as: r_cmd

  # Slow shell: read again after a pause (a zero-byte write only triggers the
  # read).
  - id: wait-output
    action: sleep
    condition: "gate == true"
    duration_ms: 1500

  - id: flush
    action: tcp_send
    handle: tn
    condition: "gate == true"
    send: ""
    timeout_secs: 5
    store_as: r_tail

  # Everything received after the command (each reply is trim_end'ed, so join
  # them with a newline).
  - id: collect
    action: script
    condition: "gate == true"
    store_as: tn_out
    code: |
      let out = "";
      for r in [r_cmd, r_tail] {
        if type_of(r.response) == "string" { out += r.response + "\n"; }
      }
      out

  # Neither the marker nor the `id` output yet: wait longer, read once more.
  - id: late-wait
    action: sleep
    condition: "gate == true && strstr(tn_out, mk.marker) == \"\" && egrep(\"uid=[0-9]+\", tn_out) == \"\""
    duration_ms: 2500

  - id: late-read
    action: tcp_send
    handle: tn
    condition: "gate == true && strstr(tn_out, mk.marker) == \"\" && egrep(\"uid=[0-9]+\", tn_out) == \"\""
    send: ""
    timeout_secs: 5
    store_as: r_late

  - id: close
    action: tcp_close
    handle: tn

  - id: collect-late
    action: script
    condition: "gate == true && type_of(r_late.response) == \"string\""
    store_as: tn_out
    code: |
      tn_out + r_late.response

  - id: check-proof
    action: script
    condition: "gate == true"
    store_as: proof_ok
    code: |
      strstr(tn_out, mk.marker) != ""

  - id: check-id
    action: script
    condition: "gate == true"
    store_as: id_ok
    code: |
      ereg("uid=[0-9]+.*gid=[0-9]+", tn_out)

  # ---------------------------------------------------------------- findings
  - id: finding-shell
    action: match
    source: proof_ok
    pattern: "^true$"
    on_match:
      finding:
        title: "Unauthenticated OS command execution on port {{port}} (Cisco ATA 187 TCP 7870, CVE-2013-1111)"
        description: "The service on port {{port}} ran an operating-system command line sent by the scanner without any login: the shell printed {{mk.marker}}, the result of an arithmetic expansion of two random numbers that never appears in the request. On a Cisco ATA 187 Analog Telephone Adaptor this is the missing access control on TCP 7870 (CVE-2013-1111); on another device it is an equally critical password-less OS shell."
        remediation: "Upgrade the Cisco ATA 187 firmware to 9.2.3.1 ES build 4 or a later release, and block TCP port 7870 from untrusted networks until then."
        confidence_delta: 0.75
        qod: 97
        evidence: "Port {{port}}: sent '{{mk.cmd}}' without logging in; the shell printed {{mk.marker}}. Output: {{tn_out}}"
      stop: true

  - id: finding-id
    action: match
    source: id_ok
    pattern: "^true$"
    condition: "proof_ok == false"
    on_match:
      finding:
        title: "Unauthenticated OS command execution on port {{port}} (Cisco ATA 187 TCP 7870, CVE-2013-1111)"
        description: "The service on port {{port}} ran the `id` command sent by the scanner without any login and returned its uid/gid output (the arithmetic proof was not evaluated by this shell). On a Cisco ATA 187 Analog Telephone Adaptor this is the missing access control on TCP 7870 (CVE-2013-1111); on another device it is an equally critical password-less OS shell."
        remediation: "Upgrade the Cisco ATA 187 firmware to 9.2.3.1 ES build 4 or a later release, and block TCP port 7870 from untrusted networks until then."
        confidence_delta: 0.55
        qod: 75
        evidence: "Port {{port}}: sent '{{mk.cmd}}' without logging in; `id` answered: {{tn_out}}"

View these feeds on GitHub