Avirt Gateway — 1 vulnerability check

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

← All products · Feeds on GitHub

Avirt Gateway Suite Telnet proxy unauthenticated command prompt

CVECVE-2002-0134
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Servicestelnet
Detectionset_var, script, tcp_open, tcp_send, sleep, tcp_close, match · highest QoD 97
Feedtests/vulnerabilities/avirt-gateway/CVE-2002-0134.yaml

The Telnet proxy of Avirt Gateway Suite 4.2 does not require authentication, and its "dos" command opens a Windows command prompt on the gateway, running as SYSTEM. The test opens a Telnet session without logging in, types "dos" and looks for a Windows drive prompt (C:\...>). It then types a harmless arithmetic command ("set /a" on two random numbers) and confirms command execution when the shell prints the result, which never appears in what the scanner sends.

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 dos on the open socket
  6. Sends … on the open socket
  7. Parses / computes the next value with a Rhai script
  8. Parses / computes the next value with a Rhai script
  9. Sends {{mk.cmd}} on the open socket
  10. Sends … on the open socket
  11. Parses / computes the next value with a Rhai script
  12. Parses / computes the next value with a Rhai script
  13. Checks proof_ok for ^true$ → finding QoD 97: Avirt Gateway Suite Telnet proxy — unauthenticated command execution (CVE-2002-0134)
  14. Checks prompt_ok for ^true$ → finding QoD 75: Avirt Gateway Suite Telnet proxy — unauthenticated command prompt (CVE-2002-0134)

References:

Feed source — tests/vulnerabilities/avirt-gateway/CVE-2002-0134.yaml
# Avirt Gateway Suite 4.2 — unauthenticated Telnet proxy "dos" command gives a
# SYSTEM command prompt (CVE-2002-0134, Strumpf Noir Society advisory, Bugtraq
# 2002-01-17).
#
# The Telnet proxy of Avirt Gateway Suite 4.2 (port 23 by default, NT service
# running as SYSTEM) asks for no credentials from any address in its allowed
# ranges. At its "Ready>" prompt, typing "dos" drops the client into a Windows
# command prompt ("C:\...>") on the gateway itself. No vendor fix was released.
#
# Ported from OpenVAS/Greenbone NVT pre2008/avirt_gateway_telnet.nasl
# (OID 1.3.6.1.4.1.25623.1.0.11096, GPL-2.0-only), which sends "dos" and
# flags a reply line matching ^[A-Z]:\\.*>.
#
# Detection:
#   1. open a Telnet session (no login), refuse any option the server asks
#      for, and type "dos";
#   2. QoD 75 — a Windows drive prompt (^[A-Z]:\.*>) comes back, as in the
#      NASL;
#   3. QoD 97 — at that prompt, type "set /a <a>*<b>" with two random 4-digit
#      numbers: cmd.exe prints the product, which never appears in what we
#      send, so an echo service or a fake prompt cannot produce it. The
#      command only multiplies two constants in the shell: nothing is run,
#      read, written or changed on the gateway.
#
# Better than the NASL (stated in the PR):
#   - proves command execution (QoD 97) instead of only matching a prompt;
#   - a prompt arriving after the first read is still collected (wait, then
#     read again);
#   - the Telnet options the server asks for are refused, as a Telnet client
#     does, before "dos" is typed.
#
# Any unauthenticated Windows shell on a Telnet port answers the same way
# ("'dos' is not recognized" then a drive prompt), so it is reported too; the
# finding text says so.
#
# category: rce (command execution as SYSTEM) + `intrusive` so scans can
# exclude it. cvss: NVD only has a v2 score (7.5) for this CVE.
uid: afc92e08-6fa8-4a8d-a62d-475d08d011a4
name: "Avirt Gateway Suite Telnet proxy unauthenticated command prompt (CVE-2002-0134)"
description: |
  The Telnet proxy of Avirt Gateway Suite 4.2 does not require authentication,
  and its "dos" command opens a Windows command prompt on the gateway, running
  as SYSTEM. The test opens a Telnet session without logging in, types "dos"
  and looks for a Windows drive prompt (C:\...>). It then types a harmless
  arithmetic command ("set /a" on two random numbers) and confirms command
  execution when the shell prints the result, which never appears in what the
  scanner sends.
cves: [CVE-2002-0134]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.20
tags: [avirt, gateway, proxy, telnet, windows, unauthenticated, rce, intrusive]
services: [telnet]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2002-0134"
  - "https://seclists.org/bugtraq/2002/Jan/225"

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

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

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

  - 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-dos-tail
    action: set_var
    var_name: r_dos2
    var_value: {response: ""}

  # "set /a <a>*<b>" and the product cmd.exe prints.
  - id: build-marker
    action: script
    store_as: mk
    code: |
      let a = rand_int(1000, 9999);
      let b = rand_int(1000, 9999);
      #{
        cmd: "set /a " + a + "*" + b,
        proof: "" + (a * b)
      }

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

  # Refuse every option the server asks for (DO x -> WONT x, WILL x -> DONT x).
  # Bytes are walked on pair boundaries, so a match never straddles two bytes.
  - id: refuse
    action: script
    condition: "conn.connected == true"
    store_as: neg
    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 }

  - id: answer
    action: tcp_send
    handle: tn
    condition: 'conn.connected == true && neg.hex != ""'
    send_hex: "{{neg.hex}}"
    timeout_secs: 2
    store_as: r_neg

  - id: send-dos
    action: tcp_send
    handle: tn
    condition: "conn.connected == true"
    send: "dos\r\n"
    timeout_secs: 5
    store_as: r_dos

  # The shell banner / prompt may come late: wait, then read again (a
  # zero-byte write only triggers the read).
  - id: wait-dos
    action: sleep
    condition: "conn.connected == true"
    duration_ms: 1500

  - id: flush-dos
    action: tcp_send
    handle: tn
    condition: "conn.connected == true"
    send: ""
    timeout_secs: 2
    store_as: r_dos2

  # Everything received after "dos" (each reply is trim_end'ed, so join them
  # with a newline to keep line starts).
  - id: collect-dos
    action: script
    condition: "conn.connected == true"
    store_as: dos_out
    code: |
      let out = "";
      for r in [r_dos, r_dos2] {
        if type_of(r.response) == "string" { out += r.response + "\n"; }
      }
      out

  - id: check-prompt
    action: script
    condition: "conn.connected == true"
    store_as: prompt_ok
    code: |
      ereg("(?m)^[A-Z]:\\\\.*>", dos_out)

  # ------------------------------------------------- command execution proof
  - id: send-cmd
    action: tcp_send
    handle: tn
    condition: "prompt_ok == true"
    send: "{{mk.cmd}}\r\n"
    timeout_secs: 5
    store_as: r_cmd

  - id: wait-cmd
    action: sleep
    condition: "prompt_ok == true"
    duration_ms: 1500

  - id: flush-cmd
    action: tcp_send
    handle: tn
    condition: "prompt_ok == true"
    send: ""
    timeout_secs: 2
    store_as: r_tail

  - id: close
    action: tcp_close
    handle: tn

  - id: collect-cmd
    action: script
    condition: "prompt_ok == true"
    store_as: cmd_out
    code: |
      let out = "";
      for r in [r_cmd, r_tail] {
        if type_of(r.response) == "string" { out += r.response + "\n"; }
      }
      out

  # The product as a whole number (not part of a longer digit run).
  - id: check-proof
    action: script
    condition: "prompt_ok == true"
    store_as: proof_ok
    code: |
      ereg("(^|[^0-9])" + mk.proof + "([^0-9]|$)", cmd_out)

  # --------------------------------------------------------------- findings
  - id: finding-exec
    action: match
    source: proof_ok
    pattern: "^true$"
    on_match:
      finding:
        title: "Avirt Gateway Suite Telnet proxy — unauthenticated command execution (CVE-2002-0134)"
        description: "The Telnet service on port {{port}} accepted the \"dos\" command without any login and opened a Windows command prompt, which evaluated '{{mk.cmd}}' and printed {{mk.proof}} (the result never appears in the request). On Avirt Gateway Suite 4.2 this shell runs as SYSTEM, so any client allowed to reach the proxy controls the gateway; on another host it is an equally critical unauthenticated Windows shell."
        remediation: "Disable the Avirt Gateway Suite Telnet proxy, or restrict its allowed IP ranges to trusted administration hosts and block TCP port 23 at the perimeter. No vendor fix was released: replace the product."
        confidence_delta: 0.75
        qod: 97
        evidence: "Port {{port}}: sent 'dos' then '{{mk.cmd}}' without logging in; the shell printed {{mk.proof}}: {{cmd_out}}"

  - id: finding-prompt
    action: match
    condition: "prompt_ok == true && proof_ok != true"
    source: prompt_ok
    pattern: "^true$"
    on_match:
      finding:
        title: "Avirt Gateway Suite Telnet proxy — unauthenticated command prompt (CVE-2002-0134)"
        description: "The Telnet service on port {{port}} answered the \"dos\" command, sent without any login, with a Windows drive prompt (C:\\...>). This is the behaviour of the Avirt Gateway Suite 4.2 Telnet proxy, whose command prompt runs as SYSTEM (on another host, an unauthenticated Windows shell or a Telnet honeypot). The scanner's arithmetic check did not print its result, so command execution was not confirmed."
        remediation: "Disable the Avirt Gateway Suite Telnet proxy, or restrict its allowed IP ranges to trusted administration hosts and block TCP port 23 at the perimeter. No vendor fix was released: replace the product."
        confidence_delta: 0.60
        qod: 75
        evidence: "Port {{port}}: sent 'dos' without logging in; reply: {{dos_out}}"

View these feeds on GitHub