← ALL ADVISORIES

MEDIUM BYTERAY-2026-0365Disclosed

wolfSSL — No-Wildcards Host Flags Ignored by TLS Handshake Hostname Verification

During the TLS handshake, wolfSSL compares the configured host name with the peer certificate using matching flags fixed at zero. Host flags set with X509_VERIFY_PARAM_set_hostflags, such as the no-wildcards flag, are never read on this path, so a certificate with a wildcard name is accepted for a host name the application asked to match literally.

Advisory
BYTERAY-2026-0365
CWE
CWE-155
CVSS
6.8 (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:N)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), OPENSSL_EXTRA or OPENSSL_ALL builds, clients that set an expected host name and request no-wildcard host flags
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

A client built with the OpenSSL compatibility layer can name the expected peer with wolfSSL_set1_host() and restrict how certificate names may match it with wolfSSL_X509_VERIFY_PARAM_set_hostflags(). The flags WOLFSSL_NO_WILDCARDS and WOLFSSL_NO_PARTIAL_WILDCARDS ask for stricter matching than the default.

The handshake does not apply those flags. Every host name comparison made while the peer certificate is processed passes the literal 0 as the matching flags. The value the application stored in ssl->param->hostFlags is not read anywhere in the handshake code. With flags of zero the matcher expands *, including partial wildcards in the left-most label.

A server or on-path attacker that holds a certificate from a trusted CA with a wildcard name such as *.example.com passes the host name check for api.example.com, although the application asked for a literal match. The session is then established with that peer. Builds without the compatibility layer have no host-flag API and are not affected.

Affected Products and Versions

  • Component: src/internal.c, CheckPeerHostName() and the host name checks in ProcessPeerCerts().
  • Required build: OPENSSL_EXTRA or OPENSSL_ALL. The host name check, wolfSSL_set1_host() and wolfSSL_X509_VERIFY_PARAM_set_hostflags() exist only with the compatibility layer.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default build without the compatibility layer does not expose the host-flag API and is not affected.
  • Other releases were not checked.

Technical Details

ProcessPeerCerts() checks the verify-parameter host name when one is set. It reads ssl->param->hostName and calls CheckPeerHostName() (src/internal.c:19454-19457). It does not read ssl->param->hostFlags. Inside CheckPeerHostName() the flags arguments are constants (src/internal.c:18172, src/internal.c:18178, src/internal.c:18187):

        if (CheckForAltNames(dCert, name, nameLen, NULL, 0, 0) != 1) {
            return DOMAIN_NAME_MISMATCH;
        }

The fifth argument of CheckForAltNames() is the matching flags. The MatchDomainName() calls on the common name pass 0 in the same way, and the other alternative-name and common-name checks in ProcessPeerCerts() pass the same constant (src/internal.c:19398, src/internal.c:19411, src/internal.c:19427, src/internal.c:19435).

  1. The application sets the expected name (src/ssl.c:7363) and the host flags (src/x509.c:10755-10760). Both are stored in ssl->param.
  2. The peer's Certificate message is decoded. Its subject alternative names and common name are chosen by the peer.
  3. The verify-parameter check calls CheckPeerHostName() with the configured name only.
  4. MatchDomainName() runs with flags of zero. It treats the pattern as wildcard-eligible (src/internal.c:14697-14702) and expands * (src/internal.c:14760-14815). WildcardPlacementOK() restricts where a wildcard may appear (src/internal.c:14655-14687) but does not disable wildcards.
  5. The wildcard name matches, no DOMAIN_NAME_MISMATCH is raised, and the handshake continues.

The certificate store path treats the same flags differently. wolfSSL_X509_verify_cert() passes hostFlags to wolfSSL_X509_check_host() (src/x509_str.c:1233-1236), which returns failure when WOLFSSL_NO_WILDCARDS or WOLFSSL_NO_PARTIAL_WILDCARDS is set (src/x509.c:16073-16084). The flag is honored or discarded depending on which path performs the check.

A second omission is in SetupStoreCtxCallback(). It copies the check time, the flags and the host name into the store context given to the verify callback, but not hostFlags (src/internal.c:16300-16317). A callback that inspects that context sees host flags of zero.

Reachability and Preconditions

  • Build with OPENSSL_EXTRA or OPENSSL_ALL.
  • The application is a TLS client that sets an expected host with wolfSSL_set1_host() or wolfSSL_X509_VERIFY_PARAM_set1_host() and sets WOLFSSL_NO_WILDCARDS or WOLFSSL_NO_PARTIAL_WILDCARDS on the same connection's verify parameters.
  • The attacker can terminate or intercept the client's connection and holds a certificate that chains to a root the client trusts, with a wildcard name that covers the configured host name.
  • TLS 1.2 and TLS 1.3 handshakes both reach ProcessPeerCerts().

Impact

The peer is accepted as the literal host name the application configured, on the strength of a wildcard certificate the application asked to reject. The attacker can then read and alter the traffic of that session. The exposure is limited to applications that use the compatibility-layer host API and request stricter matching. Applications that do not set host flags get the wildcard matching they expect.

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 pass ssl->param->hostFlags to every host name comparison in the handshake instead of the constant zero, and to give MatchDomainName() a literal mode for WOLFSSL_NO_WILDCARDS and a rejection of partial wildcards for WOLFSSL_NO_PARTIAL_WILDCARDS. Where the matcher cannot implement a requested flag, the check should fail, as wolfSSL_X509_check_host() does. SetupStoreCtxCallback() should copy hostFlags together with the host name. No build or runtime option applies the flags on the handshake path. An application that needs literal matching can compare the peer certificate's names itself, in a verify callback or after the handshake, before it sends data.

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