Bugbear — 1 vulnerability check

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

← All products · Feeds on GitHub

W32.Bugbear worm backdoor answering on the network

CVECVE-2001-0154
Severityhigh · CVSS 7.5
Categoryexposure — Exposure
Servicesunknown
Detectionset_var, tcp_open, script, tcp_send, sleep, tcp_close, match · highest QoD 75
Feedtests/vulnerabilities/bugbear/CVE-2001-0154.yaml

The W32.Bugbear mass-mailing worm (also known as Tanatos) opens a backdoor on infected Windows hosts, normally on TCP port 36794. Anyone on the network can connect to it and send one-letter commands to read data from the machine; the worm also logs keystrokes and stops antivirus and firewall software.

What the test sends: on each port reported as an unidentified service it connects, waits briefly and checks that the service has not already sent any "ID:" text by itself, then sends the single byte "p" (the backdoor's read-only listing command, no line ending). If the reply does not contain the marker yet, it waits and reads once more. Nothing on the host is changed.

What confirms the finding: the reply to "p" ends with the backdoor's "ID:" field followed by a number (higher confidence), or ends with "ID:" without a number (lower confidence). A second connection then sends a byte that is not a backdoor command: a service that answers it with an "ID:" field too (request or session IDs in error messages), that sends "ID:" before being asked, or that answers "p" without the field, is not reported. Only the "ID:" field is kept as evidence, never the rest of the reply.

How noctis detects it

  1. Opens a persistent TCP/TLS socket
  2. Parses / computes the next value with a Rhai script
  3. Sends p on the open socket
  4. Sends … on the open socket
  5. Parses / computes the next value with a Rhai script
  6. Opens a persistent TCP/TLS socket
  7. Sends # on the open socket
  8. Sends … on the open socket
  9. Parses / computes the next value with a Rhai script
  10. Checks proof.tag for ^ID:[ \t]*[0-9]+$ → finding QoD 75: W32.Bugbear worm backdoor answering on port …
  11. Checks proof.tag for ^ID:$ → finding QoD 70: W32.Bugbear worm backdoor likely answering on port …

References:

Feed source — tests/vulnerabilities/bugbear/CVE-2001-0154.yaml
# W32.Bugbear mass-mailing worm (a.k.a. Tanatos) — backdoor listening on TCP
# 36794. The worm spread through mail by abusing the Internet Explorer
# "incorrect MIME header" bug (MS01-020, CVE-2001-0154), the CVE this check is
# tracked under.
#
# Detection logic ported from the OpenVAS/Greenbone NVT bugbear.nasl
# (OID 1.3.6.1.4.1.25623.1.0.11135, GPL-2.0-only; same logic as Nessus plugin
# 11135): send the single byte "p" (no CR/LF) and look for "ID:" in the reply.
# The plugin authors note that the reply "looks random but ends with 'ID:' and
# a number" and stays under ~250 bytes. Kept as a comment: the description is
# product docs.
#
# Deviations from the NASL (fewer false positives, documented in the PR):
#   * Not tied to TCP/36794: runs on every port matched as service `unknown`
#     (nmap has no name for 36794), so a worm found on a scanned port is caught.
#   * The NASL also reports "this port is usually used by Bugbear" when the port
#     is merely open and nothing answers — dropped: an open port alone is not
#     evidence.
#   * Controls: a service that already sends "ID:" before receiving "p" (in its
#     greeting), or that answers a non-command byte ("#") with "ID:" too, is
#     not reported. "ID:" must end the reply and be a word of its own (not
#     "Session-ID:" / "UUID:"), per the plugin authors' description.
#   * A reply that arrives late or in two parts is read again before deciding.
#   * Evidence carries only the "ID:<number>" tail, never the reply body (the
#     plugin authors warn it may hold confidential data).
uid: c4e2925d-b936-416f-a64b-44330c22888e
name: "W32.Bugbear worm backdoor answering on the network"
description: |
  The W32.Bugbear mass-mailing worm (also known as Tanatos) opens a backdoor on
  infected Windows hosts, normally on TCP port 36794. Anyone on the network can
  connect to it and send one-letter commands to read data from the machine; the
  worm also logs keystrokes and stops antivirus and firewall software.

  What the test sends: on each port reported as an unidentified service it
  connects, waits briefly and checks that the service has not already sent any
  "ID:" text by itself, then sends the single byte "p" (the backdoor's
  read-only listing command, no line ending). If the reply does not contain the
  marker yet, it waits and reads once more. Nothing on the host is changed.

  What confirms the finding: the reply to "p" ends with the backdoor's
  "ID:" field followed by a number (higher confidence), or ends with "ID:"
  without a number (lower confidence). A second connection then sends a byte
  that is not a backdoor command: a service that answers it with an "ID:" field
  too (request or session IDs in error messages), that sends "ID:" before being
  asked, or that answers "p" without the field, is not reported. Only the "ID:"
  field is kept as evidence, never the rest of the reply.
cves: [CVE-2001-0154]
cvss: 7.5
severity: high
category: exposure
confidence_base: 0.30
tags: [bugbear, tanatos, worm, malware, backdoor, windows]
services: [unknown]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2001-0154"
  - "https://docs.microsoft.com/en-us/security-updates/securitybulletins/2001/ms01-020"

steps:
  # Pre-initialise everything a condition or script reads, so a silent or
  # closed port never leaves an undefined variable (that would abort the test).
  - id: init-conn
    action: set_var
    var_name: conn
    var_value: {connected: false, banner: ""}

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

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

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

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

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

  - id: init-ctl-conn
    action: set_var
    var_name: ctl_conn
    var_value: {connected: false, banner: ""}

  - id: init-ctl-hit
    action: set_var
    var_name: ctl_hit
    var_value: true

  - id: init-proof
    action: set_var
    var_name: proof
    var_value: {found: false, numbered: false, tag: ""}

  - id: open
    action: tcp_open
    handle: bb
    port: "{{port}}"
    read_banner: true
    # Runs on unknown ports: a service that never greets costs the whole
    # first-byte wait (timeout_secs), so keep it short.
    timeout_secs: 3
    store_as: conn

  # Control: the backdoor waits for a command. A service whose own greeting
  # already carries "ID:" would match without "p" having done anything.
  - id: gate-check
    action: script
    condition: "conn.connected == true"
    store_as: gate
    code: |
      let g = "";
      if type_of(conn.banner) == "string" { g = conn.banner; }
      strstr(g, "ID:") == ""

  # The single byte "p", no CR/LF.
  - id: send-p
    action: tcp_send
    handle: bb
    condition: "gate == true"
    send: "p"
    timeout_secs: 10
    store_as: r1

  # Marker not there yet: the reply may be late or come in two parts.
  - id: late-wait
    action: sleep
    condition: "gate == true && strstr(\"\" + r1.response, \"ID:\") == \"\""
    duration_ms: 1500

  - id: late-read
    action: tcp_send
    handle: bb
    condition: "gate == true && strstr(\"\" + r1.response, \"ID:\") == \"\""
    send: ""
    timeout_secs: 10
    store_as: r2

  - id: close
    action: tcp_close
    handle: bb

  - id: check
    action: script
    condition: "gate == true"
    store_as: proof
    code: |
      let out = "";
      for r in [r1, r2] {
        if type_of(r.response) == "string" { out += r.response; }
      }
      // The reply ends with the "ID:" field (a word of its own, not
      // "Session-ID:" / "UUID:"), normally followed by a number.
      let m = eregmatch("(^|[^A-Za-z0-9_-])ID:[^A-Za-z0-9]{0,3}([0-9]+)$", out);
      if m.len() > 0 {
        #{ found: true, numbered: true, tag: "ID:" + m[2] }
      } else if ereg("(^|[^A-Za-z0-9_-])ID:[^A-Za-z0-9]*$", out) {
        #{ found: true, numbered: false, tag: "ID:" }
      } else {
        #{ found: false, numbered: false, tag: "" }
      }

  # Control on a second connection: a byte that is not a backdoor command.
  # A service that answers anything with an "ID:" field (request / session
  # IDs in error messages) is not the backdoor.
  - id: ctl-open
    action: tcp_open
    handle: ctl
    port: "{{port}}"
    condition: "proof.found == true"
    read_banner: true
    timeout_secs: 10
    store_as: ctl_conn

  - id: ctl-send
    action: tcp_send
    handle: ctl
    condition: "proof.found == true"
    send: "#"
    timeout_secs: 10
    store_as: c1

  - id: ctl-wait
    action: sleep
    condition: "proof.found == true && strstr(\"\" + c1.response, \"ID:\") == \"\""
    duration_ms: 1500

  - id: ctl-late
    action: tcp_send
    handle: ctl
    condition: "proof.found == true && strstr(\"\" + c1.response, \"ID:\") == \"\""
    send: ""
    timeout_secs: 10
    store_as: c2

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

  - id: ctl-check
    action: script
    condition: "proof.found == true"
    store_as: ctl_hit
    code: |
      let out = "";
      if type_of(ctl_conn.banner) == "string" { out += ctl_conn.banner; }
      for r in [c1, c2] {
        if type_of(r.response) == "string" { out += r.response; }
      }
      strstr(out, "ID:") != ""

  - id: finding-id
    action: match
    source: proof.tag
    pattern: "^ID:[ \\t]*[0-9]+$"
    condition: "gate == true && proof.numbered == true && ctl_hit == false"
    on_match:
      finding:
        title: "W32.Bugbear worm backdoor answering on port {{port}}"
        description: "The service answered the Bugbear backdoor command 'p' with the backdoor's '{{proof.tag}}' field. The host is very likely infected by the W32.Bugbear (Tanatos) worm, which logs keystrokes and lets anyone on the network read data from the machine."
        remediation: "Isolate the host, remove the worm with an up-to-date antivirus tool, change the passwords typed on it, close open Windows shares and apply Microsoft security bulletin MS01-020 (Internet Explorer incorrect MIME header)."
        confidence_delta: 0.50
        qod: 75
        evidence: "no 'ID:' before the command nor in reply to a non-command byte; reply to 'p' ends with '{{proof.tag}}' (reply body withheld)"
      stop: true

  - id: finding-bare
    action: match
    source: proof.tag
    pattern: "^ID:$"
    condition: "gate == true && proof.found == true && proof.numbered == false && ctl_hit == false"
    on_match:
      finding:
        title: "W32.Bugbear worm backdoor likely answering on port {{port}}"
        description: "The service answered the Bugbear backdoor command 'p' with a reply ending in 'ID:' (without the number that usually follows). The host is likely infected by the W32.Bugbear (Tanatos) worm."
        remediation: "Isolate the host, remove the worm with an up-to-date antivirus tool, change the passwords typed on it, close open Windows shares and apply Microsoft security bulletin MS01-020 (Internet Explorer incorrect MIME header)."
        confidence_delta: 0.40
        qod: 70
        evidence: "no 'ID:' before the command nor in reply to a non-command byte; reply to 'p' ends with 'ID:' (reply body withheld)"

View these feeds on GitHub