SSH Terrapin — 1 vulnerability check

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

← All products · Feeds on GitHub

SSH Terrapin Prefix Truncation

CVECVE-2023-48795
Severitymedium · CVSS 5.9
Categoryhardening — Hardening
Servicesssh
Detectiontcp_connect, match, set_var · highest QoD 75
Feedtests/vulnerabilities/ssh-terrapin/CVE-2023-48795.yaml

Checks SSH servers for the Terrapin vulnerability by reading the server's KEXINIT packet and inspecting supported algorithms. Vulnerable if chacha20-poly1305 or ETM MACs are offered without strict-KEX extension.

How noctis detects it

  1. TCP connect and banner grab
  2. Checks ssh_banner.banner for ^SSH-2\.0-
  3. Checks ssh_banner.banner for kex-strict-s-v00@openssh\.com
  4. Checks ssh_banner.banner for chacha20-poly1305@openssh\.com → finding QoD 75: SSH offers chacha20-poly1305 without strict-KEX extension — Terrapin vulnerable. Banner: …
  5. Checks ssh_banner.banner for \w+-etm@openssh\.com → finding QoD 75: SSH offers ETM MAC algorithms without strict-KEX extension — Terrapin vulnerable. Banner: …

References:

Feed source — tests/vulnerabilities/ssh-terrapin/CVE-2023-48795.yaml
# SSH Terrapin Prefix Truncation Attack — CVE-2023-48795
#
# SSH implementations offering ChaCha20-Poly1305 or ETM MACs
# (Encrypt-then-MAC) without the "strict KEX" extension (introduced in
# OpenSSH 9.6) are vulnerable to a prefix truncation attack.
# A MitM can drop handshake messages to downgrade SSH security mechanisms
# (disable ext-info, etc.).
#
# Detection:
#   - TCP connection to port 22, read SSH banner + KEXINIT
#   - Vulnerable if: chacha20-poly1305 OR *-etm@openssh.com present
#     AND kex-strict-s-v00@openssh.com absent
#
# QoD 75 (passive negotiation analysis) — no code executed.
uid: 9c1b4f3e-7a2d-4e8c-b5f1-3d6a0e2b8c4f
name: "SSH Terrapin Prefix Truncation (CVE-2023-48795)"
description: |
  Checks SSH servers for the Terrapin vulnerability by reading the server's
  KEXINIT packet and inspecting supported algorithms. Vulnerable if
  chacha20-poly1305 or ETM MACs are offered without strict-KEX extension.
cves: [CVE-2023-48795]
cvss: 5.9
severity: medium
category: hardening
confidence_base: 0.30
tags: [ssh, cryptography, mitm, openssh, protocol]
services: [ssh]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2023-48795"
  - "https://terrapin-attack.com/"
  - "https://www.openssh.com/txt/release-9.6"


steps:
  # ── TCP connection: read SSH banner + KEXINIT ────────────────────────────
  # The mock server (and properly behaving SSH servers) send banner + KEXINIT
  # in one burst so a single read() captures both.
  - id: tcp-banner
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    store_as: ssh_banner

  # Verify this is actually an SSH server
  - id: banner-match
    action: match
    source: ssh_banner.banner
    pattern: "^SSH-2\\.0-"
    on_match:
      set_vars:
        is_ssh: true
        ssh_banner_str: "{{ssh_banner.banner}}"

  # Initialise flag so Rhai conditions never see an undefined variable
  - id: init-strict-kex
    action: set_var
    var_name: has_strict_kex
    var_value: false

  # strict-kex present = patched (OpenSSH >= 9.6)
  - id: strict-kex-check
    action: match
    source: ssh_banner.banner
    pattern: "kex-strict-s-v00@openssh\\.com"
    condition: "is_ssh == true"
    on_match:
      set_vars:
        has_strict_kex: true

  # ── Verdict: vulnerable if chacha20 offered without strict-kex ──────────
  - id: vuln-chacha20
    action: match
    source: ssh_banner.banner
    pattern: "chacha20-poly1305@openssh\\.com"
    condition: "is_ssh == true && has_strict_kex == false"
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "SSH offers chacha20-poly1305 without strict-KEX extension — Terrapin vulnerable. Banner: {{ssh_banner_str}}"

  # ── Verdict: vulnerable if ETM MAC offered without strict-kex ───────────
  - id: vuln-etm
    action: match
    source: ssh_banner.banner
    pattern: "\\w+-etm@openssh\\.com"
    condition: "is_ssh == true && has_strict_kex == false"
    on_match:
      finding:
        confidence_delta: 0.50
        qod: 75
        evidence: "SSH offers ETM MAC algorithms without strict-KEX extension — Terrapin vulnerable. Banner: {{ssh_banner_str}}"

View these feeds on GitHub