wolfSSL — Delimiter Injection in ALPN Peer Protocol List
wolfSSL_ALPN_GetPeerProtocol returns the ALPN names offered by a TLS client as one comma-separated C string and copies each name unchanged. A client can put a comma, a NUL or CR/LF inside a protocol name, so an application that splits or logs the string sees entries, a truncation point or lines that the client chose.
- Advisory
- BYTERAY-2026-0447
- CWE
- CWE-140
- 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), servers built with HAVE_ALPN whose application reads the client's protocol list with wolfSSL_ALPN_GetPeerProtocol
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
A server application can ask wolfSSL for the list of ALPN protocol names the client offered. wolfSSL_ALPN_GetPeerProtocol() returns them as a single NUL-terminated string with a comma between names.
The names come from the ClientHello. The parser checks that the length fields are consistent and stores the bytes as received. The getter copies each name as it is and adds the commas. No byte value is rejected or escaped at either step.
A client can therefore send a protocol name that contains a comma, which the application sees as two names. A name containing a NUL cuts the string short for anything that uses strlen(), while the returned length still reports the full size. CR and LF bytes split lines in logs. No memory is corrupted, and wolfSSL's own ALPN selection is not affected because it works on the length-delimited form. The effect is limited to applications that use this string, in builds where ALPN support is enabled.
Affected Products and Versions
- Component:
src/ssl_api_ext.c,wolfSSL_ALPN_GetPeerProtocol(). The stored bytes come fromTLSX_ALPN_ParseAndSet()insrc/tls.c. - Required build:
HAVE_ALPN. The--enable-alpnoption is off by default (configure.ac:9275-9277); some other configure options turn ALPN on. - Required use: a server application that calls this getter and splits, compares or logs the result.
- Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- Other releases were not checked.
Technical Details
The parser validates framing only. It checks the two-byte list size and each one-byte entry length, and rejects an entry of length zero or one that runs past the extension (src/tls.c:2061-2077). It then stores the raw list (src/tls.c:2100).
The getter converts that list in one loop (src/ssl_api_ext.c:794-810). In effect it replaces each length byte with a comma and leaves the name bytes as they are.
The path from the wire to the application:
- A TLS client sends the ALPN extension in its ClientHello.
TLSX_ALPN_ParseAndSet()stores the protocol name list inssl->alpn_peer_requestedwithout inspecting the name bytes. - The getter sets
*listSzto the stored length minus one (src/ssl_api_ext.c:785). - It writes a comma before every entry after the first (
src/ssl_api_ext.c:798-800) and copies the entry bytes unchanged (src/ssl_api_ext.c:809). - It terminates the buffer with a NUL (
src/ssl_api_ext.c:814).
The bounds are correct: one separator or terminator is written for each length byte consumed. What is missing is any neutralisation of the separator inside names. Two entries h2 and h3,http/0.9 are returned as h2,h3,http/0.9, which reads as three protocols. With an embedded NUL, *listSz is larger than strlen() of the returned string.
The comma-separated form is the one the library itself consumes on the way in: wolfSSL_UseALPN() splits its argument on commas (src/ssl_api_ext.c:713-715). An application that feeds the peer list back through it, or splits it the same way, works with boundaries the client chose. The example server prints the string with %s (examples/server/server.c:3966-3969).
Reachability and Preconditions
- Build with
HAVE_ALPN, and ALPN configured on the server withwolfSSL_UseALPN(). - The application calls
wolfSSL_ALPN_GetPeerProtocol()and treats the result as a comma-separated list or writes it to a line-oriented log. - The attacker is any TLS client that can connect to the server.
- No authentication is needed. The data is in the ClientHello.
Impact
An application that splits the returned string on commas sees protocol names the client did not send as separate entries. That can defeat a per-entry allowlist or an exact-list comparison built on this string. An embedded NUL hides the rest of the list from string functions while the reported length disagrees. CR and LF bytes forge or split log lines. Inside wolfSSL the only consumer is the example server's log line, so the impact depends on how the embedding application uses the string. There is no memory-safety impact.
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 protocol names when the extension is parsed: reject an entry that contains a comma, a NUL, CR or LF, or anything outside printable ASCII, and fail the handshake. That protects every consumer. As an alternative or in addition, the getter can escape those bytes, or the library can offer an accessor that returns each name with its length. Applications should treat the returned list as client-controlled. Compare names against an expected set before acting on them, do not rely on strlen() agreeing with the returned length, and sanitise the string before logging it.
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
wolfSSL_ALPN_GetPeerProtocolat the tested commit- ALPN list validation and storage in
TLSX_ALPN_ParseAndSetat the tested commit - BYTERAY-2026-0448, delimiter injection in
wolfSSL_X509_get_name_oneline - BYTERAY-2026-0449, delimiter injection in
wolfSSL_X509_NAME_oneline - BYTERAY-2026-0450, delimiter injection in subjectAltName printing