From 8013175ec9432e4e612582ecfb608ef6505bc02b Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 20 Nov 2026 10:29:16 -0800 Subject: [PATCH] certs: warn when wolfSSL is older than 5.9.4 wolfSSL before 5.9.4 applies only the issuing CA's name constraints to a cert (CVE-2026-89133). Peer chains verify one cert at a time, so a peer-supplied CA can then issue a leaf outside a trusted CA's namespace. - configure warns after the summary when certs are on - internal.h defines WOLFSSH_CERTS_OLD_NAME_CONSTRAINTS for that case - certman.c raises a #warning from it, or #pragma message under MSVC, in builds without config.h Issue: F-13950 --- configure.ac | 23 +++++++++++++++++++++++ src/certman.c | 10 ++++++++++ wolfssh/internal.h | 5 +++++ 3 files changed, 38 insertions(+) diff --git a/configure.ac b/configure.ac index 04879a020..ab6b33910 100644 --- a/configure.ac +++ b/configure.ac @@ -431,6 +431,25 @@ AS_IF([test "x$ENABLED_AGENT" = "xyes"], [AM_CPPFLAGS="$AM_CPPFLAGS -DWOLFSSH_AGENT"]) AS_IF([test "x$ENABLED_CERTS" = "xyes"], [AM_CPPFLAGS="$AM_CPPFLAGS -DWOLFSSH_CERTS"]) + +# wolfSSL before 5.9.4 skips ancestor name constraints (CVE-2026-89133). +CERTS_OLD_WOLFSSL=no +AS_IF([test "x$ENABLED_CERTS" = "xyes"],[ + AC_MSG_CHECKING([whether wolfSSL applies every CA's name constraints]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#ifdef WOLFSSL_USER_SETTINGS + #include + #else + #include + #endif + #include ]], + [[#if LIBWOLFSSL_VERSION_HEX < 0x05009004 + #error "older than 5.9.4" + #endif]])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + CERTS_OLD_WOLFSSL=yes])]) + AS_IF([test "x$ENABLED_OSSH_CERTS" = "xyes"], [AM_CPPFLAGS="$AM_CPPFLAGS -DWOLFSSH_OSSH_CERTS"]) dnl Initialize before the feature block so a stray WINCERT_LIBS value in the @@ -655,3 +674,7 @@ AS_ECHO([" * X.509 Certs: $ENABLED_CERTS"]) AS_ECHO([" * OpenSSH Certs: $ENABLED_OSSH_CERTS"]) AS_ECHO([" * Windows cert store: $ENABLED_WINDOWS_CERT_STORE"]) AS_ECHO([" * Examples: $ENABLED_EXAMPLES"]) + +AS_IF([test "x$CERTS_OLD_WOLFSSL" = "xyes"], + [AC_MSG_WARN([X.509 certs are on, but this wolfSSL is older than 5.9.4 and does not apply the name constraints of CAs above a cert's issuer (CVE-2026-89133). A peer-supplied CA can authenticate a name outside its namespace. Upgrade wolfSSL to 5.9.4 or later.])], + [:]) diff --git a/src/certman.c b/src/certman.c index bf71bcc4f..34770188f 100644 --- a/src/certman.c +++ b/src/certman.c @@ -84,6 +84,16 @@ #ifdef WOLFSSH_CERTS +/* configure warns on its own and builds with -Werror */ +#if defined(WOLFSSH_CERTS_OLD_NAME_CONSTRAINTS) && !defined(HAVE_CONFIG_H) + #ifdef _MSC_VER + #pragma message("warning: wolfSSL older than 5.9.4 does not apply " \ + "ancestor CA name constraints (CVE-2026-89133); upgrade wolfSSL") + #else + #warning "wolfSSL older than 5.9.4 does not apply ancestor CA name constraints (CVE-2026-89133); upgrade wolfSSL" + #endif +#endif + #ifdef NO_INLINE #include #else diff --git a/wolfssh/internal.h b/wolfssh/internal.h index 9d12659e3..31b2139a4 100644 --- a/wolfssh/internal.h +++ b/wolfssh/internal.h @@ -142,6 +142,11 @@ extern "C" { #define WOLFSSH_CERTMAN_CHAIN_CA #endif +/* wolfSSL before 5.9.4 skips ancestor name constraints (CVE-2026-89133). */ +#if defined(WOLFSSH_CERTS) && (LIBWOLFSSL_VERSION_HEX < WOLFSSL_V5_9_4) + #define WOLFSSH_CERTS_OLD_NAME_CONSTRAINTS +#endif + /* wc_MlDsaKey_* / WC_MLDSA_* naming replaced the wc_Dilithium_* API in * wolfSSL 5.9.2. HAVE_DILITHIUM alone doesn't distinguish the two, so * require the version that has the new API too. */