← ALL ADVISORIES

LOW BYTERAY-2026-0539Disclosed

wolfSSL — One-Sided Expiration Check in Session Cache Lookup

wolfSSL_GetSessionFromCache rejects a cached session only when the current time is past its creation time plus its timeout. After a backward step of the server clock, an entry that had already expired passes the check again and can be resumed for roughly the size of the rollback.

Advisory
BYTERAY-2026-0539
CWE
CWE-324
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), servers that resume sessions by session ID from the internal session cache
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

A server that resumes sessions by session ID looks the entry up in its session cache. wolfSSL_GetSessionFromCache() decides whether the entry has expired by comparing the current time with the entry's creation time plus its timeout.

The comparison is an upper bound only. It rejects an entry that has lived too long. It does not reject an entry whose creation time is ahead of the current clock. If the server clock steps backwards, an entry that had already expired passes the check again and is returned for resumption.

The resuming party is the one that already held the session, and it cannot cause the clock step. The consequence is that the configured session lifetime is not enforced for roughly the size of the rollback. No secret is disclosed. The path is the default session-ID resumption through the session cache.

Affected Products and Versions

  • Component: src/ssl_sess.c, wolfSSL_GetSessionFromCache(), the session cache lookup used for session-ID resumption.
  • Required build: the internal session cache, with session-ID resumption in use on the server.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The session cache lookup is part of the default resumption path. The issue shows only after the server clock moves backwards.
  • Other releases were not checked.

Technical Details

wolfSSL_GetSessionFromCache() (src/ssl_sess.c:1243) applies one time-based rejection, at src/ssl_sess.c:1413:

else if (LowResTimer() >= (sess->bornOn + sess->timeout)) {
    WOLFSSL_MSG("Invalid session: timed out");
    sess = NULL;

The values are word32. The test fires when the session has lived too long. There is no lower bound that rejects an entry whose bornOn is later than the current clock. For such an entry the condition is false, the eviction branch (src/ssl_sess.c:1414-1426) does not run, and the function reaches its success path (src/ssl_sess.c:1433).

bornOn is not taken from the wire. It is set from LowResTimer() when the session is created (src/ssl_sess.c:3818) or restored from a serialized session (src/ssl_sess.c:2980). It is only as fresh as the clock that stamped it.

  1. A ClientHello with a session ID reaches the non-ticket path of HandleTlsResumption(), which calls wolfSSL_GetSession() (src/internal.c:41665).
  2. wolfSSL_GetSession() (src/ssl_sess.c:1532) calls wolfSSL_GetSessionFromCache().
  3. The entry is fetched under a read lock (src/ssl_sess.c:1386) and passes CheckSessionMatch() (src/ssl_sess.c:1408), which is not a time check.
  4. The comparison at src/ssl_sess.c:1413 is the only lifetime check. After a backward clock step, LowResTimer() is below bornOn + timeout again and the entry is returned as valid.

The same resumption flow has a second lifetime check in HandleTlsResumption() (src/internal.c:41699-41701) with the same shape. It is described in BYTERAY-2026-0538. Neither check compensates for the other.

Reachability and Preconditions

  • The server resumes sessions by session ID from the internal session cache.
  • The server clock steps backwards: an NTP correction, a virtual machine migration or a manual time change. The attacker cannot force this.
  • The attacker holds a session ID that the server issued earlier and presents it in a ClientHello. It is the legitimate holder of that session.
  • No further authentication is involved beyond the original handshake that created the session.

Impact

A cached session is accepted for resumption after its intended expiration. The extension is bounded by roughly the size of the clock rollback. The resuming party already held the session, so this is not impersonation of another principal and no session key material is disclosed. The loss is that the server's expiration policy is not enforced.

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 a relative-age test: subtract bornOn from the current time and compare the result with the timeout. An entry stamped in the future then produces a large wrapped age and is rejected. Entries whose bornOn is ahead of the clock should also be rejected or clamped when a session is created and when it is restored from a serialized blob. The check in HandleTlsResumption() needs the same change, since fixing one leaves the other open. Where the platform has one, a monotonic time source avoids the problem.

Operationally, slewing the server clock instead of stepping it backwards avoids the precondition.

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