wolfSSL — Host Flags Dropped by X509_VERIFY_PARAM Inheritance When the Source Has No Host Name
wolfSSL_X509_VERIFY_PARAM_inherit copies the host-matching flags only inside the branch that copies the host name. When the source parameter carries flags such as the no-wildcards flag but no host name, the flags are dropped without an error, and store-side host name verification then accepts wildcard certificate names the application asked to reject.
- Advisory
- BYTERAY-2026-0366
- 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 builds, applications that inherit host flags from a verify parameter with no host name and check host names through wolfSSL_X509_verify_cert
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
A WOLFSSL_X509_VERIFY_PARAM holds two separate host settings: the expected peer name, and host flags that control how certificate names may match it. wolfSSL_X509_VERIFY_PARAM_inherit() merges one parameter object into another. It is used whenever verify parameters are propagated, for example from a context to a connection or into a certificate store.
The function copies the host flags only when it also copies the host name. If the source parameter sets flags but has an empty host name, or the destination already has a host name and no overwrite is requested, the flags are discarded. The other policy bits are still merged and the call reports success.
On the certificate store verification path the dropped flags arrive as zero. A certificate with the name *.example.com, or a partial wildcard such as a*.example.com, is then accepted for api.example.com although the application asked for WOLFSSL_NO_WILDCARDS. The function exists only in OPENSSL_EXTRA builds, and the common pattern of setting the name and the flags on the same parameter is not affected.
Affected Products and Versions
- Component:
src/x509.c,wolfSSL_X509_VERIFY_PARAM_inherit(). - Required build:
OPENSSL_EXTRA. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default build without the compatibility layer does not include this function.
- Other releases were not checked.
Technical Details
The host flags assignment sits inside the host name guard (src/x509.c:10658-10664):
if (isOverWrite ||
(from->hostName[0] != 0 && (to->hostName[0] == 0 || isDefault))) {
if (!(ret = wolfSSL_X509_VERIFY_PARAM_set1_host(to, from->hostName,
(unsigned int)XSTRLEN(from->hostName))))
return ret;
to->hostFlags = from->hostFlags;
}
The generic flags are merged a few lines later without any such condition (src/x509.c:10677). The wildcard policy therefore depends on the presence of a source host name instead of being treated as a field of its own.
- The destination parameter carries the reference name, for example
api.example.com. - A source parameter carries
hostFlags = WOLFSSL_NO_WILDCARDSand an emptyhostName. It is merged throughwolfSSL_X509_VERIFY_PARAM_set1()(src/x509.c:10746), which is reached fromwolfSSL_CTX_set1_param()(src/ssl.c:7385),wolfSSL_X509_STORE_set1_param()(src/x509_str.c:2778),wolfSSL_X509_STORE_CTX_init()(src/x509_str.c:254) and the per-connection parameter setup (src/internal.c:8950). - The guard is false.
to->hostFlagskeeps its previous value, zero for a new parameter. wolfSSL_X509_verify_cert()callswolfSSL_X509_check_host()withctx->param->hostFlags(src/x509_str.c:1232-1243).- With flags of zero, the checks that return failure for
WOLFSSL_NO_WILDCARDSandWOLFSSL_NO_PARTIAL_WILDCARDS(src/x509.c:16073-16084) are not taken.MatchDomainName()expands the*in the certificate name.
Reachability and Preconditions
- Build with
OPENSSL_EXTRA. - The application inherits a source parameter that sets
WOLFSSL_NO_WILDCARDSorWOLFSSL_NO_PARTIAL_WILDCARDSwith no host name, or inherits into a destination whose host name is already set withoutWOLFSSL_VPARAM_OVERWRITEorWOLFSSL_VPARAM_DEFAULT. - Host name checking is performed through
wolfSSL_X509_verify_cert()with a host name in the parameter. - The attacker presents a certificate that chains to the verifier's trust store and has a wildcard name covering the reference name.
Impact
The certificate is accepted for the literal host name the application configured, on the strength of a wildcard name the application asked to reject. Where that decision authenticates a TLS peer, the attacker can read and alter the traffic of the session. The exposure depends on the application using the flags-only inheritance pattern.
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 move the hostFlags copy out of the host name guard and merge it as an independent policy field, with the same overwrite and default semantics as the other fields. The existing tests set the source host name and the host flags together before each case (tests/api/test_ossl_x509_vp.c:73-79), so they do not cover a flags-only source or a destination that already has a host name. Both cases should be added. The TLS handshake path ignores hostFlags for a separate reason, described in BYTERAY-2026-0365. Until then, applications can call wolfSSL_X509_VERIFY_PARAM_set_hostflags() directly on the parameter that carries the host name, or set the name and the flags on the same source parameter. In that pattern both fields are propagated correctly.
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.