← ALL ADVISORIES

MEDIUM BYTERAY-2026-0404Disclosed

wolfSSL — Unregistered Flows Bound to the Last Registered Server in Sniffer Server Lookup

In the wolfSSL sniffer, GetSnifferServer returns the last entry of the server list when no registered server matches a new connection. The caller checks only for NULL, so the flow is accepted and bound to that server's SSL context instead of being rejected as not registered.

Advisory
BYTERAY-2026-0404
CWE
CWE-697
CVSS
6.5 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), sniffer builds without WOLFSSL_SNIFFER_WATCH
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

The wolfSSL sniffer keeps a list of registered servers, each an address and a port. For every new TCP connection it sees, GetSnifferServer() finds the registered server the connection belongs to. A connection that matches none is supposed to be rejected with a "server not registered" error.

When the list walk reaches the last entry without a match, the loop exits with its cursor still on that entry, and the function returns it. No match and a match look the same to the caller, which checks only for NULL.

A connection that matches no registered server is therefore accepted and bound to whichever server is last in the list. The sniffer creates two wolfSSL objects from that server's context, with its keys, and stores a session under the connection's addresses and ports. Anyone whose traffic passes the capture point can create such sessions. There is no memory corruption. The sniffer is not part of a default build.

Affected Products and Versions

  • Component: src/sniffer.c, GetSnifferServer(), called from CreateSession().
  • Required build: the sniffer (--enable-sniffer, configure.ac:3162) without WOLFSSL_SNIFFER_WATCH. In watch mode the lookup loop is not compiled.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not include the sniffer.
  • Other releases were not checked.

Technical Details

The lookup loop (src/sniffer.c:1706-1718) breaks when an entry's port and address match the source side or the destination side of the packet. Otherwise it advances:

        if (sniffer->next)
            sniffer = sniffer->next;
        else
           break;
    }

On the last node the else branch breaks without setting sniffer to NULL (src/sniffer.c:1716-1717). The function then returns sniffer (src/sniffer.c:1726), which is the final node.

How a packet gets there and what follows:

  1. ssl_DecodePacketInternal() calls CheckHeaders() with registration checking on (src/sniffer.c:7160-7161) and then CheckSession() (src/sniffer.c:7168).
  2. CheckHeaders() drops a packet only when neither address is registered (src/sniffer.c:5848-5852) or neither port is registered (src/sniffer.c:5864-5871). These are two separate tests. They do not require that a registered port and its own registered address appear together.
  3. For a SYN without ACK (src/sniffer.c:5907), CheckSession() calls CreateSession() (src/sniffer.c:5922), which calls GetSnifferServer() (src/sniffer.c:5654).
  4. GetSnifferServer() needs a port and its paired address on the same side. If no entry satisfies that, it returns the last entry.
  5. CreateSession() tests only session->context == NULL (src/sniffer.c:5655), so the SERVER_NOT_REG_STR rejection (src/sniffer.c:5656) is not taken. It creates the server and client wolfSSL objects from the returned context (src/sniffer.c:5661, src/sniffer.c:5667) and inserts the session into the session table (src/sniffer.c:5688-5689). A comment there states the assumption that does not hold: "we know the server is one we care about as we've passed the GetSnifferServer() successfully" (src/sniffer.c:5700-5702).

Example: one server (A, 443) is registered. A SYN from A:54321 to B:443, where B is not registered, passes both pre-filters, because A is a registered address and 443 is a registered port. It matches no entry in the walk and is bound to A's entry.

Reachability and Preconditions

  • The sniffer is built without WOLFSSL_SNIFFER_WATCH and has at least one registered server.
  • The attacker's packets pass the capture point. A remote client of a monitored service qualifies. Source addresses can be spoofed.
  • A TCP SYN that has a registered address on one side and a registered port on either side, but no matching pair, is enough.
  • No authentication is involved. A registered server's own outbound connection to an unregistered peer has the same effect.

Impact

The sniffer processes flows that are outside its registration policy. It attempts to decode them with another server's context and key, attributes its output and statistics to the wrong server, and allocates a session and two wolfSSL objects for each such flow. A stream of such SYNs churns the session table and per-session memory, limited by the removal of stale sessions. The handshake of such a flow is also the input to the named-key lookup described in BYTERAY-2026-0536.

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 set sniffer to NULL in the branch that handles the end of the list, or to track a match with an explicit flag and return NULL unless one was recorded. CreateSession() then rejects the flow with SERVER_NOT_REG_STR as written. A regression test with one registered server and a SYN to an unregistered address on the registered port would cover it. ByteRay knows of no configuration workaround. Filtering the capture so that only traffic to and from the registered address and port pairs reaches the sniffer keeps unmatched flows away from the lookup.

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