OpenSSH (regreSSHion) — 1 vulnerability check

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

← All products · Feeds on GitHub

OpenSSH regreSSHion Pre-Auth RCE

CVECVE-2024-6387
Severityhigh · CVSS 8.1
Categoryrce — Remote code execution
Servicesssh
Detectionssh_check, script, match · highest QoD 70
Feedtests/vulnerabilities/regresshion/CVE-2024-6387.yaml

Race condition in the OpenSSH sshd SIGALRM handler (grace_alarm_handler). When a client does not complete authentication within LoginGraceTime, sshd calls async-signal-unsafe functions, which allows heap corruption and unauthenticated root code execution on Linux/glibc systems. The test connects to the SSH service and reads its identification string. It reports OpenSSH 8.5p1 to 9.7p1, and versions before 4.4p1 (where the same flaw first appeared as CVE-2006-5051). Fixed in 9.8p1. Debian, Raspbian and Ubuntu builds print their package revision in the identification string; revisions that carry the vendor fix (Debian 12 9.2p1-2+deb12u3, Debian 9.7p1-7, Ubuntu 22.04 8.9p1-3ubuntu0.10, Ubuntu 23.10 9.3p1-1ubuntu3.6, Ubuntu 24.04 9.6p1-3ubuntu13.3 and later) are not reported. Upstream portable builds without a vendor suffix ("OpenSSH_9.7p1") are reported with high confidence. Other builds whose identification string does not show a patch level (a vendor suffix, or no portable "p" release as on Red Hat Enterprise Linux and OpenBSD) are reported with lower confidence, since a backported fix cannot be ruled out from the version string alone.

How noctis detects it

  1. SSH banner and authentication-method probe
  2. Parses / computes the next value with a Rhai script
  3. Checks ver.banner for OpenSSH_ → finding QoD 70: SSH identification string shows a vulnerable OpenSSH version (< 4.4p1 or 8.5p1–9.7p1, upstream build or unfixed Debian/Ubuntu revision): …
  4. Checks ver.banner for OpenSSH_ → finding QoD 50: SSH identification string shows an OpenSSH version in the vulnerable range from a build whose patch level the identification string does no…

References:

Feed source — tests/vulnerabilities/regresshion/CVE-2024-6387.yaml
# Version check from the SSH identification string. The exploit itself is a
# hours-long race against the SIGALRM handler and cannot be run safely, so the
# banner is the only evidence (QoD 70).
#
# Affected (NVD cpe): OpenSSH < 4.4p1 (re-introduced CVE-2006-5051) and
# 8.5p1 – 9.7p1; fixed in 9.8p1.
# Distribution backports keep the upstream version and only change the
# package suffix (issue #2414). Fixed revisions per vendor advisory:
#   Debian 12 bookworm   1:9.2p1-2+deb12u3   (DSA-5724-1)
#   Debian trixie/sid    1:9.7p1-7
#   Ubuntu 24.04 noble   1:9.6p1-3ubuntu13.3 (USN-6859-1)
#   Ubuntu 23.10 mantic  1:9.3p1-1ubuntu3.6
#   Ubuntu 22.04 jammy   1:8.9p1-3ubuntu0.10
#   Ubuntu 24.10 oracular ships 9.7p1-7ubuntuN (fixed Debian base)
# Debian/Raspbian/Ubuntu banners print the package revision after the
# version ("OpenSSH_9.2p1 Debian-2+deb12u3"), so those are compared exactly.
# Any other vendor suffix (FreeBSD-2024xxxx, …) cannot be mapped: reported at
# QoD 50. Upstream portable builds always print "pN" ("OpenSSH_9.7p1"), so only
# that form without a suffix is QoD 70. A banner with no "pN" ("OpenSSH_8.7")
# comes from RHEL/Alma/Rocky (fix backported, RHSA-2024:4312, banner unchanged)
# or OpenBSD's native sshd (not exploitable per Qualys): QoD 50.
uid: 480e74ed-259d-40d9-9b98-b220b161eb4f
name: "OpenSSH regreSSHion Pre-Auth RCE (CVE-2024-6387)"
description: |
  Race condition in the OpenSSH sshd SIGALRM handler (grace_alarm_handler).
  When a client does not complete authentication within LoginGraceTime,
  sshd calls async-signal-unsafe functions, which allows heap corruption and
  unauthenticated root code execution on Linux/glibc systems.
  The test connects to the SSH service and reads its identification string.
  It reports OpenSSH 8.5p1 to 9.7p1, and versions before 4.4p1 (where the
  same flaw first appeared as CVE-2006-5051). Fixed in 9.8p1.
  Debian, Raspbian and Ubuntu builds print their package revision in the
  identification string; revisions that carry the vendor fix (Debian 12
  9.2p1-2+deb12u3, Debian 9.7p1-7, Ubuntu 22.04 8.9p1-3ubuntu0.10, Ubuntu
  23.10 9.3p1-1ubuntu3.6, Ubuntu 24.04 9.6p1-3ubuntu13.3 and later) are not
  reported. Upstream portable builds without a vendor suffix
  ("OpenSSH_9.7p1") are reported with high confidence. Other builds whose
  identification string does not show a patch level (a vendor suffix, or no
  portable "p" release as on Red Hat Enterprise Linux and OpenBSD) are
  reported with lower confidence, since a backported fix cannot be ruled out
  from the version string alone.
cves: [CVE-2024-6387]
cvss: 8.1
severity: high
category: rce
confidence_base: 0.20
tags: [ssh, openssh, rce, race-condition, kev, regresshion]
services: [ssh]
author: noctis
version: "1.1.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2024-6387"
  - "https://www.qualys.com/2024/07/01/cve-2024-6387/regresshion.txt"
  - "https://www.openssh.com/txt/release-9.8"
  - "https://security-tracker.debian.org/tracker/CVE-2024-6387"
  - "https://ubuntu.com/security/CVE-2024-6387"

steps:
  - id: ssh-banner
    action: ssh_check
    port: "{{port}}"
    timeout_secs: 10
    store_as: ssh_resp

  # Parse "SSH-2.0-OpenSSH_<maj>.<min>[p<n>][ <vendor suffix>]" and decide.
  # status: "upstream" (pN, no suffix), "distro" (Debian/Raspbian/Ubuntu revision
  # known to be unfixed), "unchecked" (other suffix), "fixed" / "not-affected".
  - id: version
    action: script
    condition: "ssh_resp.connected == true"
    store_as: ver
    code: |
      let b = ssh_resp.banner;
      if type_of(b) != "string" { b = ""; }
      let m = eregmatch("OpenSSH_([0-9]+)\\.([0-9]+)(p[0-9]+)?[^ ]*( +(.*))?$", b);
      if type_of(m) != "array" || m.len() < 3 {
        #{ ok: false, vuln: false, checked: false, banner: b, status: "not-openssh" }
      } else {
        let maj = int(m[1]);
        let min = int(m[2]);
        let tail = "";
        if m.len() > 5 { tail = m[5]; }
        let old = maj < 4 || (maj == 4 && min < 4);
        let modern = (maj == 8 && min >= 5) || (maj == 9 && min <= 7);
        let status = "not-affected";
        if old || modern {
          let d = eregmatch("^(Debian|Raspbian|Ubuntu)-([^ ]+)", tail);
          if tail == "" && m[3] != "" {
            status = "upstream";
          } else if modern && type_of(d) == "array" && d.len() >= 3 {
            let rev = d[2];
            let fixed = false;
            let base = 0;
            let r = eregmatch("^([0-9]+)", rev);
            if type_of(r) == "array" && r.len() >= 2 { base = int(r[1]); }
            // Debian 12: 9.2p1-2+deb12uN, N >= 3
            let u = eregmatch("\\+deb12u([0-9]+)", rev);
            if maj == 9 && min == 2 && type_of(u) == "array" && u.len() >= 2 && int(u[1]) >= 3 { fixed = true; }
            // Debian trixie/sid (and Ubuntu 24.10 on top of it): 9.7p1-7 and later
            if maj == 9 && min == 7 && base >= 7 { fixed = true; }
            // Ubuntu: <base>ubuntu<x>[.<y>], compared as a tuple
            let ub = eregmatch("^([0-9]+)ubuntu([0-9]+)(\\.([0-9]+))?", rev);
            if type_of(ub) == "array" && ub.len() >= 3 {
              let x = int(ub[2]);
              let y = 0;
              if ub.len() >= 5 { y = int(ub[4]); }
              let fb = -1; let fx = 0; let fy = 0;
              if maj == 8 && min == 9 { fb = 3; fx = 0; fy = 10; }
              if maj == 9 && min == 3 { fb = 1; fx = 3; fy = 6; }
              if maj == 9 && min == 6 { fb = 3; fx = 13; fy = 3; }
              if fb >= 0 && (base > fb || (base == fb && (x > fx || (x == fx && y >= fy)))) { fixed = true; }
            }
            if fixed { status = "fixed"; } else { status = "distro"; }
          } else {
            status = "unchecked";
          }
        }
        let vuln = status == "upstream" || status == "distro" || status == "unchecked";
        let checked = status == "upstream" || status == "distro";
        #{ ok: true, vuln: vuln, checked: checked, banner: b, status: status }
      }

  - id: vulnerable-version
    action: match
    condition: "ver.vuln == true && ver.checked == true"
    source: ver.banner
    pattern: "OpenSSH_"
    on_match:
      finding:
        confidence_delta: 0.50
        qod: 70
        evidence: "SSH identification string shows a vulnerable OpenSSH version (< 4.4p1 or 8.5p1–9.7p1, upstream build or unfixed Debian/Ubuntu revision): {{ver.banner}}"
      stop: true

  - id: vulnerable-version-unchecked-backport
    action: match
    condition: "ver.vuln == true && ver.checked == false"
    source: ver.banner
    pattern: "OpenSSH_"
    on_match:
      finding:
        confidence_delta: 0.30
        qod: 50
        evidence: "SSH identification string shows an OpenSSH version in the vulnerable range from a build whose patch level the identification string does not show (vendor suffix or no portable release); a backported fix is possible: {{ver.banner}}"
      stop: true

View these feeds on GitHub