wolfSSL — Address Family Mismatch Between the OCSP Responder Screen and the IPv6 Connect Fallback
In builds with the opt-in OCSP responder screen, IPv6 enabled and no getaddrinfo, the screen checks the resolver's IPv4 answer while the connect routine copies the same four bytes into the top of an IPv6 address and dials that. The destination is never the one that was checked. No blocked range becomes reachable; OCSP lookups by host name go to the wrong address and fail.
- Advisory
- BYTERAY-2026-0437
- CWE
- CWE-180
- CVSS
- 3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.4, builds with WOLFSSL_OCSP_SCREEN_RESPONDER and WOLFSSL_IPV6 on platforms without getaddrinfo
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL can screen the host of an OCSP responder URL before it connects, so that a URL taken from a certificate cannot point the request at loopback, link-local or private addresses. The screen is compiled only with WOLFSSL_OCSP_SCREEN_RESPONDER.
On platforms without getaddrinfo, both the screen and the connect routine fall back to gethostbyname, which returns IPv4 addresses. The screen checks those four bytes against its IPv4 list. The connect routine, when built with WOLFSSL_IPV6, creates an IPv6 socket address and copies the same four bytes into the start of the 16-byte IPv6 address field. An answer of 203.0.113.10 is checked as IPv4 and dialed as cb00:710a::.
The screen and the connect therefore disagree about the destination. ByteRay checked whether this lets a URL reach a destination the screen is meant to block. It does not: every IPv6 range the screen would block needs a first byte that the IPv4 list already rejects. The effect that remains is that the OCSP request is sent to an address nobody vetted, and in practice the lookup fails. Three non-default build conditions are required.
Affected Products and Versions
- Component:
src/wolfio.c,wolfIO_TcpConnect()(connect) andwolfIO_OcspDestAllowed()(screen), used by the default OCSP lookup callbackEmbedOcspLookup(). - Required build:
WOLFSSL_OCSP_SCREEN_RESPONDER(a macro the integrator defines; no configure option sets it),WOLFSSL_IPV6(--enable-ipv6, off by default,configure.ac:3410-3419), andHAVE_GETADDRINFOnot defined (configure.ac:250detects the function). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
v5.9.2-stabledoes not contain the responder screen, so there is no mismatch to speak of; its connect fallback has the same IPv6 copy.v5.9.4-stablecontains both. Not fixed on master.- A default
./configurebuild is not affected. Earlier releases were not checked.
Technical Details
The screen's fallback passes each gethostbyname answer to wolfIO_OcspIPv4Blocked() (src/wolfio.c:2448-2453). The IPv6 list, wolfIO_OcspIPv6Blocked(), is not compiled in this configuration (src/wolfio.c:2294-2297).
The connect fallback, src/wolfio.c:1519-1524:
if (entry) {
#ifdef WOLFSSL_IPV6
sin = (SOCKADDR_IN6 *)&addr;
sin->sin6_family = AF_INET6;
sin->sin6_port = XHTONS(port);
XMEMCPY(&sin->sin6_addr, entry->h_addr_list[0], entry->h_length);
addr was cleared at src/wolfio.c:1473, and the socket is created with its family at src/wolfio.c:1545.
EmbedOcspLookup()decodes the URL and calls the screen with the host name (src/wolfio.c:2503-2510).- The screen resolves the name with
gethostbyname_r()orgethostbyname()(src/wolfio.c:2432,src/wolfio.c:2436) and tests each answer as IPv4. EmbedOcspLookup()callswolfIO_TcpConnect()with the same name (src/wolfio.c:2530).- The connect resolves again and writes the four answer bytes to bytes 0 to 3 of
sin6_addr. Bytes 4 to 15 stay zero.
The dialed address is aabb:ccdd:: for an answer a.b.c.d. It is not the IPv4-compatible form ::a.b.c.d, which would put the bytes at the end. An answer passes wolfIO_OcspIPv4Blocked() only if its first octet is between 1 and 223 (src/wolfio.c:2272, src/wolfio.c:2287). The dialed IPv6 address then has a first byte between 0x01 and 0xDF. Unique-local, link-local and multicast addresses start with 0xFC or higher. Loopback, the unspecified address, IPv4-mapped and NAT64 addresses start with 0x00. None can be produced.
Reachability and Preconditions
- The three build conditions above, and OCSP checking enabled at run time with the default lookup callback.
- An OCSP responder URL that uses a host name. The URL comes from the certificate's Authority Information Access extension or from the configured override URL.
- No attacker is needed for the misdirection: every responder host name is affected. A party who controls the DNS answer chooses the top 32 bits of the dialed address and nothing else.
Impact
Confirmed from source: the destination that is dialed is not the destination that was screened, and it is an IPv6 address derived from an IPv4 answer. OCSP lookups by host name in this configuration do not reach the responder. Whether that fails the handshake depends on the application's revocation policy.
Not supported by the source: a bypass of the screen. The addresses that can be produced are limited to those with 96 zero low bits and a first byte from 0x01 to 0xDF, none of which is in a range the screen blocks for either family. No confidentiality impact was established.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
Not fixed on wolfSSL master as of commit e4b0841b32e7 (2026-12-03).
The fix direction is for the connect fallback to build the socket address in the family the resolver returned, an IPv4 address for an AF_INET answer, and for the screen to pass the address it checked to the connect instead of the host name. The second change also closes the gap described in BYTERAY-2026-0364.
Workaround: build with getaddrinfo available, or without WOLFSSL_IPV6. Either removes the mismatch. Applications can also install their own OCSP I/O callback with wolfSSL_CTX_SetOCSP_Cb.
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.