← ALL ADVISORIES

LOW BYTERAY-2026-0535Disclosed

wolfSSL — DTLS 1.2 Cookie Exchange Skipped on Session ID Cache Hit Without Context Binding

With WOLFSSL_DTLS_NO_HVR_ON_RESUME, a DTLS 1.2 server skips the cookie exchange when the ClientHello session ID matches any entry in the process-wide session cache. The match is not tied to the receiving context, so a known session ID lets spoofed ClientHellos reach stateful handshake processing.

Advisory
BYTERAY-2026-0535
CWE
CWE-639
CVSS
3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), DTLS 1.2 servers built with WOLFSSL_DTLS_NO_HVR_ON_RESUME
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

A DTLS server normally answers a first ClientHello with a HelloVerifyRequest and keeps no state until the client returns the cookie. That proves the client's source address before the server does any handshake work. The optional WOLFSSL_DTLS_NO_HVR_ON_RESUME build skips this exchange for ClientHellos that look like a resumption.

For session IDs, "looks like a resumption" is decided by TlsSessionIdIsValid(). It looks the client's session ID up in the process-wide session cache and treats any hit as a resumption. The lookup compares the ID bytes and the connection side. It does not check that the cached session belongs to the WOLFSSL_CTX that received the ClientHello, and it applies none of the checks the real resumption path applies later.

Session IDs travel in cleartext. Anyone who knows one ID in the cache, including the ID of their own earlier session, can send ClientHellos from spoofed addresses and have the server go stateful without address validation. The effect is on availability only. The option is off by default. wolfSSL's change log entry for it already says that forged ClientHellos carrying a collected session ID will consume server resources; this advisory is about the match being a bare cache hit.

Affected Products and Versions

  • Component: src/dtls.c, TlsSessionIdIsValid(), reached from DoClientHelloStateless().
  • Required build: DTLS with WOLFSSL_DTLS_NO_HVR_ON_RESUME (src/dtls.c:426). The path applies to DTLS 1.2 ClientHellos that are not first fragments (src/dtls.c:1081).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The option is not defined in a default build. Without it this code is not compiled.
  • Other releases were not checked.

Technical Details

TlsSessionIdIsValid() (src/dtls.c:461-519) calls TlsSessionCacheGetAndRdLock() with the session ID from the wire (src/dtls.c:504). The cache row match is on sessionID and side (src/ssl_sess.c:1199-1200), and the cache is shared by every WOLFSSL_CTX in the process. A hit sets *resume = TRUE (src/dtls.c:513).

CheckSessionMatch() is the function that ties a cached session to the receiving object. It is called from src/ssl_sess.c:1304 and src/ssl_sess.c:1408, on the stateful lookup. It is not called here. The external-cache branch (src/dtls.c:480-496) accepts a result from the application's get_sess_cb in the same way.

The decision path:

  1. The ClientHello session ID is attacker-chosen cleartext.
  2. DoClientHelloStateless() calls TlsResumptionIsValid() for DTLS 1.2 ClientHellos that are not first fragments (src/dtls.c:1081-1083), which calls TlsSessionIdIsValid() (src/dtls.c:533).
  3. Any cache entry with that ID and side sets resume.
  4. The caller sets ssl->options.dtlsStateful = 1 and returns (src/dtls.c:1086-1089). The cookie check and the stateless reply (src/dtls.c:1093-1122) are never reached.

The flag set in step 4 is the one the validated-cookie path sets (src/dtls.c:1124). A raw cache hit therefore stands in for the cookie round trip.

Reachability and Preconditions

  • Server built with WOLFSSL_DTLS_NO_HVR_ON_RESUME and a session cache; DTLS 1.2.
  • At least one session ID is in the process-wide cache and known to the attacker. The attacker's own earlier session is enough. An ID observed on the wire from another context in the same process also works.
  • The attacker can send UDP datagrams to the listener, with spoofed source addresses if desired. No authentication is needed.

Impact

A client that has not proved its source address drives the server into stateful handshake processing. This allows state exhaustion against the listener and use of the server's handshake replies for amplification toward a spoofed address.

It does not complete a resumption. Adopting the session still requires the master secret, which the Finished message proves, so there is no authentication, confidentiality or integrity impact and no takeover of another context's session. The missing context binding adds no capability beyond what the attacker's own session ID gives.

Much of this is the stated cost of the option. The change log entry that introduced it describes it as off by default to favor security and notes that a collected session ID lets forged ClientHellos consume server resources (ChangeLog.md, line 3025). What goes beyond that description is that the waiver is granted before any check that the receiving context would resume the session.

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 validate the cache hit against the receiving object before honoring it: call CheckSessionMatch(), or an equivalent binding to the receiving WOLFSSL_CTX, before setting resume, and do the same for sessions returned by get_sess_cb. The cookie exchange should be waived only for a session this context would resume.

Workaround: leave WOLFSSL_DTLS_NO_HVR_ON_RESUME undefined unless resumption without a HelloVerifyRequest is needed. That compiles the path out.

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.

References