nfs-utils — 1 vulnerability check

noctis ships 1 vulnerability check for nfs-utils, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Linux rpc.statd syslog format string (nfs-utils < 0.1.9.1 / kstatd, remote root)

CVECVE-2000-0666, CVE-2000-0800
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Servicesrpcbind, sunrpc
Detectionset_var, tcp_dialogue, udp_probe, script, match · highest QoD 70
Feedtests/vulnerabilities/nfs-utils/rpc-statd-format-string.yaml

Detects a Linux NFS status monitor (rpc.statd from nfs-utils before 0.1.9.1, or the SuSE kstatd daemon) that passes the host name of a status request to syslog as a format string, which lets an unauthenticated attacker run code as root. The feed asks the portmapper on the scanned port (PMAPPROC_GETPORT, over TCP and UDP) where RPC program 100024 version 1 listens, sends an RPC NULL call (procedure 0, a no-op) to that port to confirm statd answers, and sends a NULL call for portmapper version 3 to tell a legacy portmap (version 2 only, as on the affected 2000-era Linux releases) from a modern rpcbind. A live statd behind a legacy portmap is reported; a statd behind rpcbind is not. No status request and no format string are sent, and statd keeps running. The nfs-utils version cannot be read over RPC, so an updated statd on an old system that still runs portmap is reported as well: check the installed package.

How noctis detects it

  1. TCP dialogue: one binary protocol frame
  2. UDP datagram probe
  3. Parses / computes the next value with a Rhai script
  4. TCP dialogue: one binary protocol frame
  5. UDP datagram probe
  6. TCP dialogue: one binary protocol frame
  7. UDP datagram probe
  8. Parses / computes the next value with a Rhai script
  9. Checks v.hit for ^true$ → finding QoD 70: rpc.statd on a legacy portmap host (CVE-2000-0666, CVE-2000-0800)

References:

Feed source — tests/vulnerabilities/nfs-utils/rpc-statd-format-string.yaml
# Linux nfs-utils rpc.statd / SuSE kstatd syslog format string — CVE-2000-0666
# (rpc.statd, nfs-utils < 0.1.9.1, CERT CA-2000-17) and CVE-2000-0800 (SuSE
# kstatd, same flaw). The daemon logs the monitor name of an SM_STAT / SM_MON
# call through syslog() as the format string, so "%n" sequences in the name
# write to memory: unauthenticated remote root.
#
# Credit: detection target adapted from Greenbone's
# `2011/gb_nfs_rpc_statd_mult_format_string_vuln.nasl` (GPL-2.0-only). That check
# sends SM_STAT("N") over UDP to see statd answer, then SM_STAT with a 40-byte
# "n%n%n%..." name and reports when no reply comes back, i.e. when statd died.
# That crash probe is a denial of service (NFS file locking on the host breaks
# until statd is restarted) and is NOT ported.
#
# Why no exploit proof: the format string is expanded inside syslog() only; the
# RPC reply is the same for any name (STAT_FAIL when the name does not resolve),
# so nothing benign is observable on the wire, and the RPC interface exposes no
# nfs-utils version. Only the crash shows the bug.
#
# Improvement over the source check — a fingerprint that does not flag every
# NFS host: a bare "statd answers" check reports every current Linux NFS
# client or server (rpc.statd runs wherever NFSv3 locking does). The affected
# releases (Red Hat 6.x/7.0, Debian 2.2, SuSE 6.x/7.0, Mandrake 7.x, Conectiva,
# 2000) all ran Wietse Venema's portmap 4.0, which serves the portmapper protocol
# version 2 only; distributions moved to rpcbind (versions 2, 3 and 4) years
# after the fix. The feed therefore reports statd only when:
#   1. rpcbind (PMAPPROC_GETPORT) maps program 100024 v1 to a port, over TCP or
#      UDP (the source check uses UDP),
#   2. that port answers an RPC NULL call for program 100024 (procedure 0, a
#      no-op that logs nothing — the scanner sends no SM_STAT at all), and
#   3. the portmapper answers a NULL call for its own version 3 with
#      PROG_MISMATCH (highest version 2), i.e. it is a legacy portmap.
# A modern rpcbind (SUCCESS for v3) gives no finding: that is a deliberate
# false negative for the impossible case of a 2000-era statd behind rpcbind.
# Limitation: systems that kept portmap 4.0 with a fixed statd (e.g. RHEL 5,
# Debian up to 6, old NAS firmware) and other Unix hosts with a v2-only
# portmapper and their own statd (e.g. AIX) are reported too — hence QoD 70.
#
# 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 | 28+L result
#   (PROG_MISMATCH result: 28+L low version, 32+L high version)
uid: b3b9bd8e-8add-4ad6-8b1e-b20c05f55f59
name: "Linux rpc.statd syslog format string (nfs-utils < 0.1.9.1 / kstatd, remote root)"
description: |
  Detects a Linux NFS status monitor (rpc.statd from nfs-utils before 0.1.9.1,
  or the SuSE kstatd daemon) that passes the host name of a status request to
  syslog as a format string, which lets an unauthenticated attacker run code as
  root. The feed asks the portmapper on the scanned port (PMAPPROC_GETPORT, over
  TCP and UDP) where RPC program 100024 version 1 listens, sends an RPC NULL call
  (procedure 0, a no-op) to that port to confirm statd answers, and sends a NULL
  call for portmapper version 3 to tell a legacy portmap (version 2 only, as on
  the affected 2000-era Linux releases) from a modern rpcbind. A live statd
  behind a legacy portmap is reported; a statd behind rpcbind is not. No status
  request and no format string are sent, and statd keeps running. The nfs-utils
  version cannot be read over RPC, so an updated statd on an old system that
  still runs portmap is reported as well: check the installed package.
category: rce
cves: [CVE-2000-0666, CVE-2000-0800]
cvss: 10.0
severity: critical
confidence_base: 0.30
tags: [linux, nfs, nfs-utils, statd, kstatd, rpc, sunrpc, portmap, format-string, cert-ca-2000-17]
services: [rpcbind, sunrpc]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2000-0666"
  - "https://nvd.nist.gov/vuln/detail/CVE-2000-0800"
  - "https://www.cert.org/advisories/CA-2000-17.html"
  - "http://www.securityfocus.com/bid/1480"
  - "https://www.rfc-editor.org/rfc/rfc5531"

steps:
  # ── 1. Ask the portmapper where statd (100024 v1) listens, over TCP and UDP.
  # PMAPPROC_GETPORT (100000 v2 proc 3) args {100024, 1, 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\x30".
  - id: getport-tcp
    action: tcp_dialogue
    port: "{{port}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000384e4f43300000000000000002000186a0000000020000000300000000000000000000000000000000000186b8000000010000000600000000"
    store_as: gpt

  # Over UDP, asking for the UDP port, xid "NOC\x31".
  - id: getport-udp
    action: udp_probe
    port: "{{port}}"
    timeout_secs: 5
    send_hex: "4e4f43310000000000000002000186a0000000020000000300000000000000000000000000000000000186b8000000010000001100000000"
    store_as: gpu

  - id: parse-getport
    action: script
    store_as: mp
    code: |
      let pt = 0;
      let pu = 0;
      let pm_tcp = false;
      let pm_udp = false;
      if gpt.connected == true && type_of(gpt.response_hex) == "string" {
        let h = tolower(gpt.response_hex);
        if strlen(h) >= 64 && substr(h, 8, 15) == "4e4f4330"
            && 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 {
            pm_tcp = true;
            pt = u32be(substr(h, off + 8, off + 15));
          }
        }
      }
      if gpu.responded == true && type_of(gpu.response_hex) == "string" {
        let h = "80000000" + tolower(gpu.response_hex);
        if strlen(h) >= 64 && substr(h, 8, 15) == "4e4f4331"
            && 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 {
            pm_udp = true;
            pu = u32be(substr(h, off + 8, off + 15));
          }
        }
      }
      let rt = pt > 0 && pt < 65536;
      let ru = pu > 0 && pu < 65536;
      #{ pt: pt, pu: pu, pm_tcp: pm_tcp, pm_udp: pm_udp,
         query_tcp: rt && pt != port, query_udp: ru && pu != port }

  # ── 2. Ping the statd port(s) rpcbind returned: RPC NULL (100024 v1 proc 0).
  - id: init-statd-tcp
    action: set_var
    var_name: st
    var_value: {connected: false}

  - id: init-statd-udp
    action: set_var
    var_name: su
    var_value: {responded: false}

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

  # UDP, xid "NOC\x33".
  - id: null-statd-udp
    action: udp_probe
    condition: "mp.query_udp == true"
    port: "{{mp.pu}}"
    timeout_secs: 5
    send_hex: "4e4f43330000000000000002000186b8000000010000000000000000000000000000000000000000"
    store_as: su

  # ── 3. Legacy portmap or rpcbind? RPC NULL for portmapper version 3 (100000 v3 proc 0)
  # on the scanned port: rpcbind answers SUCCESS, portmap 4.0 answers PROG_MISMATCH 2..2.
  - id: init-pmv3-tcp
    action: set_var
    var_name: vt
    var_value: {connected: false}

  - id: init-pmv3-udp
    action: set_var
    var_name: vu
    var_value: {responded: false}

  # TCP, xid "NOC\x34" — only when the portmapper answered over TCP.
  - id: pmv3-tcp
    action: tcp_dialogue
    condition: "mp.pm_tcp == true && (mp.query_tcp == true || mp.query_udp == true)"
    port: "{{port}}"
    tls: false
    read_banner: false
    timeout_secs: 10
    send_hex: "800000284e4f43340000000000000002000186a0000000030000000000000000000000000000000000000000"
    store_as: vt

  # UDP, xid "NOC\x35" — when the portmapper answered over UDP only.
  - id: pmv3-udp
    action: udp_probe
    condition: "mp.pm_tcp == false && mp.pm_udp == true && (mp.query_tcp == true || mp.query_udp == true)"
    port: "{{port}}"
    timeout_secs: 5
    send_hex: "4e4f43350000000000000002000186a0000000030000000000000000000000000000000000000000"
    store_as: vu

  - id: verdict
    action: script
    store_as: v
    code: |
      // statd alive: accept_stat SUCCESS (0) or PROG_MISMATCH (2) for program 100024.
      let ht = if mp.query_tcp && st.connected == true && type_of(st.response_hex) == "string" { tolower(st.response_hex) } else { "" };
      let hu = if mp.query_udp && su.responded == true && type_of(su.response_hex) == "string" { "80000000" + tolower(su.response_hex) } else { "" };
      let alive_t = false;
      let alive_u = false;
      if strlen(ht) >= 56 && substr(ht, 8, 15) == "4e4f4332"
          && 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) == "4e4f4333"
          && 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)));
      }
      // Portmapper version 3: legacy = PROG_MISMATCH with highest supported version 2.
      let hv = "";
      let xv = "";
      if mp.pm_tcp && vt.connected == true && type_of(vt.response_hex) == "string" {
        hv = tolower(vt.response_hex);
        xv = "4e4f4334";
      } else if !mp.pm_tcp && mp.pm_udp && vu.responded == true && type_of(vu.response_hex) == "string" {
        hv = "80000000" + tolower(vu.response_hex);
        xv = "4e4f4335";
      }
      let legacy = false;
      let pmap = "unknown";
      if xv != "" && strlen(hv) >= 56 && substr(hv, 8, 15) == xv
          && u32be(substr(hv, 16, 23)) == 1 && u32be(substr(hv, 24, 31)) == 0 {
        let vl = u32be(substr(hv, 40, 47));
        let off = 48 + ((vl + 3) / 4) * 8;
        if vl <= 400 && strlen(hv) >= off + 8 {
          let acc = u32be(substr(hv, off, off + 7));
          if acc == 0 {
            pmap = "rpcbind (answers portmapper v3)";
          } else if acc == 2 && strlen(hv) >= off + 24 {
            let lo = u32be(substr(hv, off + 8, off + 15));
            let hi = u32be(substr(hv, off + 16, off + 23));
            legacy = hi == 2 && lo <= 2;
            pmap = "portmap serving versions " + lo + " to " + hi;
          }
        }
      }
      let where = if alive_t { "TCP port " + mp.pt } else if alive_u { "UDP port " + mp.pu } else { "" };
      #{ hit: (alive_t || alive_u) && legacy, where: where, pmap: pmap }

  # ── 4. Finding ──────────────────────────────────────────────────────────────
  - id: statd-legacy
    action: match
    source: v.hit
    pattern: "^true$"
    condition: "v.hit == true"
    on_match:
      finding:
        title: "rpc.statd on a legacy portmap host (CVE-2000-0666, CVE-2000-0800)"
        description: "rpc.statd (RPC program 100024 v1) answered an RPC NULL call, and the portmapper only serves protocol version 2, as the 2000-era Linux releases that shipped the vulnerable statd did. rpc.statd from nfs-utils before 0.1.9.1, and the SuSE kstatd daemon, pass the host name of a status request to syslog as a format string, which lets an unauthenticated remote attacker execute code as root. The statd version cannot be read over RPC."
        remediation: "Upgrade nfs-utils to 0.1.9.1 or later (or the vendor's fixed knfsd/nfs-utils package; SuSE: the fixed knfsd/kstatd), or stop rpc.statd where NFS file locking is not needed, and firewall the portmapper (111) and the RPC port range from untrusted networks."
        confidence_delta: 0.40
        qod: 70
        evidence: "rpc.statd (RPC 100024 v1) on {{v.where}} answered an RPC NULL call (rpcbind on port {{port}}: {{v.pmap}})"

View these feeds on GitHub