wolfSSL — Missing Named Key Reported as Success in Sniffer SNI Key Lookup
In the wolfSSL sniffer, LoadNamedKey returns success when no registered named key matches the server name in a ClientHello. The session continues with no private key, the caller's diagnostic is never recorded, and the server name is missing from the monitoring output.
- Advisory
- BYTERAY-2026-0536
- CWE
- CWE-697
- CVSS
- 3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 (tested at master commit d95483f), sniffer builds with HAVE_SNI where private keys are registered only as named keys
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
The wolfSSL sniffer decodes captured TLS traffic. With SNI support it can hold private keys registered against server names, called named keys. When a ClientHello carries a server name, LoadNamedKey() looks for the key registered under that name and loads it into the session.
The function sets its return value to 0, meaning success, before it searches, and changes it only when a name matches. If no key matches, it returns 0 with no key loaded. The caller treats only a negative value as a failure, so the diagnostic it has for this case is never recorded.
The session carries on without a private key. Decryption of that flow fails later with no explanation, and the serverNameIndication field in the monitoring output is left empty. Any client can cause this by offering a name that is not registered. It is a monitoring-integrity defect. It is not memory corruption and it discloses nothing. The sniffer is not part of a default build, and deployments that register a key per server are not affected.
Affected Products and Versions
- Component:
src/sniffer.c,LoadNamedKey(), called fromProcessClientHello(). - Required build: the sniffer (
--enable-sniffer,configure.ac:3162) withHAVE_SNI, and keys registered only as named keys, so the server's context has no default key. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include the sniffer. - Other releases were not checked.
Technical Details
The comment above the function states its contract: "Function return value must be 0 for success" (src/sniffer.c:4313). The body (src/sniffer.c:4314-4350) starts with int ret = 0; (src/sniffer.c:4316) and walks the list of named keys:
while (namedKey != NULL) {
if (nameSz == namedKey->nameSz &&
XSTRNCMP((char*)name, namedKey->name, nameSz) == 0) {
/* load the key, set ret, set session->sni */
break;
}
namedKey = namedKey->next;
}
return ret;
ret is assigned only inside the match body (src/sniffer.c:4325-4343). That is also the only place that loads a key and sets session->sni. If the loop reaches the end of the list without a match, the function returns 0 at src/sniffer.c:4349.
How the result is used:
ProcessClientHello()callsLoadNamedKey()for a host-name entry in the server name extension and testsret < 0(src/sniffer.c:4517-4522). In that branch it records the non-fatalCLIENT_HELLO_LATE_KEY_STRerror. A zero return never takes it.- A named key is stored only in the sniffer's
namedKeyslist (src/sniffer.c:2071-2077). With named-key-only registration the server's context has no default key, so a session whose name matched nothing has no private key at all. - The session information reports
serverNameIndicationfromsession->sni(src/sniffer.c:2464-2469), which is still NULL.
Reachability and Preconditions
- The sniffer is built with
HAVE_SNIand keys are registered as named keys only. - A monitored client sends a ClientHello whose server name differs from every registered name on the selected server.
- The client needs no authentication and no special position. Its traffic only has to pass the capture point.
- Together with BYTERAY-2026-0404, a flow bound to the wrong server entry also ends up here, because that server's named keys do not include the name the client offered.
Impact
The operator loses two things for the affected flow: the error that says no key was available, and the server name the client asked for. The flow is not decrypted either way, since no key is loaded on either path. The difference is that the failure is silent and the session is not attributed.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
ByteRay has not confirmed a fixed wolfSSL release for this issue as of 2026-12-03, and has not checked it against wolfSSL changes made after the tested commit.
The fix direction is to make "no key found" an error: start ret at a negative value and set it to 0 only in the match body, or return an explicit error after the loop. The caller's existing ret < 0 branch then records the diagnostic as intended. Setting session->sni from the offered name whether or not a key matched would keep the attribution. Workaround: the affected configuration is named-key-only registration. Registering a default key for each server as well means that a session whose name matches no named key still has a key.
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.