NTPsec — 1 vulnerability check

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

← All products · Feeds on GitHub

NTPsec < 0.9.7 multiple vulnerabilities (CVE-2014-9295, CVE-2017-6451/6458/6463/6464)

CVECVE-2014-9295, CVE-2017-6451, CVE-2017-6458, CVE-2017-6463, CVE-2017-6464
Severityhigh · CVSS 8.8
Categoryexposure — Exposure
Servicesntp
Ports123
Detectionudp_probe, script, match · highest QoD 70
Feedtests/vulnerabilities/ntpsec/CVE-2014-9295.yaml

NTPsec releases before 0.9.7 contain several memory-safety and denial-of-service flaws: stack-based buffer overflows reintroduced in the code (CVE-2014-9295), an improper snprintf() use in mx4200_send() (CVE-2017-6451), potential overflows in the ctl_put*() control functions (CVE-2017-6458), and denial of service through a malformed or malicious configuration (CVE-2017-6463, CVE-2017-6464). The test sends a standard NTP mode-6 (control) read-variables request to the NTP service and reads the "version" system variable of the reply. It reports a daemon identifying itself as NTPsec with a version lower than 0.9.7. No exploit payload is sent, since the overflows would crash the daemon.

How noctis detects it

  1. UDP datagram probe
  2. Parses / computes the next value with a Rhai script
  3. Checks ver.version for ^[0-9]+[.][0-9]+[.][0-9]+$ → finding QoD 70: NTPsec < 0.9.7 multiple vulnerabilities

References:

Feed source — tests/vulnerabilities/ntpsec/CVE-2014-9295.yaml
# NTPsec before 0.9.7 — version check from the mode-6 "version" system variable.
# The flaws (stack/heap overflows, config-parsing DoS) are memory-corruption bugs
# in the daemon; running them would crash ntpd, so the reported version is the
# only safe evidence (QoD 70). Fixed in NTPsec 0.9.7.
uid: 74f6a0d6-a7ba-4809-b8b0-82c835b8991f
name: "NTPsec < 0.9.7 multiple vulnerabilities (CVE-2014-9295, CVE-2017-6451/6458/6463/6464)"
description: |
  NTPsec releases before 0.9.7 contain several memory-safety and denial-of-service
  flaws: stack-based buffer overflows reintroduced in the code (CVE-2014-9295),
  an improper snprintf() use in mx4200_send() (CVE-2017-6451), potential overflows
  in the ctl_put*() control functions (CVE-2017-6458), and denial of service
  through a malformed or malicious configuration (CVE-2017-6463, CVE-2017-6464).
  The test sends a standard NTP mode-6 (control) read-variables request to the
  NTP service and reads the "version" system variable of the reply. It reports a
  daemon identifying itself as NTPsec with a version lower than 0.9.7. No
  exploit payload is sent, since the overflows would crash the daemon.
cves: [CVE-2014-9295, CVE-2017-6451, CVE-2017-6458, CVE-2017-6463, CVE-2017-6464]
# NVD v3.x score of CVE-2017-6458 (the highest of the chain; CVE-2014-9295 has no v3 score)
cvss: 8.8
severity: high
category: exposure
confidence_base: 0.30
tags: [ntp, ntpsec, buffer-overflow, dos, version]
services: [ntp]
ports: [123]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-9295"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6451"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6458"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6463"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6464"

steps:
  - id: ntp-readvar
    action: udp_probe
    port: "{{port}}"
    # mode 6 (control), version 4, opcode 2 (readvar), seq 1, assoc 0 (system), no data
    send_hex: "260200010000000000000000"
    timeout_secs: 5
    store_as: ntp

  # The reply has a binary header, so the engine reports it as hex only: match the
  # hex of  version="ntpsec-<maj>.<min>[.<patch>]  and turn the ASCII digits back
  # into numbers (0x30-0x39 -> "3" + digit, 0x2e = ".").
  - id: version
    action: script
    condition: "ntp.responded == true && type_of(ntp.response_hex) == \"string\""
    store_as: ver
    code: |
      let m = eregmatch("76657273696f6e3d226e74707365632d((?:3[0-9])+)2e((?:3[0-9])+)(?:2e((?:3[0-9])+))?", ntp.response_hex);
      if type_of(m) != "array" || m.len() < 3 {
        #{ vuln: false, version: "" }
      } else {
        let a = int(ereg_replace("3([0-9])", "${1}", m[1]));
        let b = int(ereg_replace("3([0-9])", "${1}", m[2]));
        let c = 0;
        if m.len() > 3 && m[3] != "" { c = int(ereg_replace("3([0-9])", "${1}", m[3])); }
        #{ vuln: a == 0 && (b < 9 || (b == 9 && c < 7)), version: "" + a + "." + b + "." + c }
      }

  - id: vulnerable-version
    action: match
    condition: "ver.vuln == true"
    source: ver.version
    pattern: "^[0-9]+[.][0-9]+[.][0-9]+$"
    on_match:
      finding:
        title: "NTPsec < 0.9.7 multiple vulnerabilities"
        description: "The NTP service identifies itself as NTPsec {{ver.version}}, older than the fixed 0.9.7 release."
        remediation: "Upgrade NTPsec to 0.9.7 or later."
        confidence_delta: 0.40
        qod: 70
        evidence: "mode-6 version variable reports NTPsec {{ver.version}} (< 0.9.7)"

View these feeds on GitHub