wolfSSL — CR/LF Injection in Certificate Subject and Issuer Names Printed by wolfSSL_X509_print
The certificate text dump in wolfSSL's OpenSSL compatibility layer writes subject and issuer name values to the output without escaping control characters. A certificate whose name contains CR or LF adds lines of the sender's choosing to the printed text. Applications that print peer certificates into logs or other line-based output are affected.
- Advisory
- BYTERAY-2026-0351
- CWE
- CWE-144
- CVSS
- 5.3 (CVSS:3.1/AV:N/AC:L/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 through 5.9.4, builds with OPENSSL_EXTRA (--enable-opensslextra) whose application prints untrusted certificates with wolfSSL_X509_print
- Fixed in
- Master commit b1a13054ea93064bf87e38f03daf7e30e698149a (PR 11682, merged 2026-10-15). Not in a wolfSSL stable release as of 2026-12-03.
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL_X509_print, wolfSSL_X509_print_ex and wolfSSL_X509_print_fp produce a human-readable dump of a certificate. The Issuer: and Subject: lines are written by one helper, which asks the name printer for no escaping at all.
Name values come straight from the certificate. A value that contains CR or LF is written as it is, so the dump gains extra lines whose content the certificate author chose. In a log, an audit trail or a text report, those lines are indistinguishable from lines the application wrote. The print functions are part of the OpenSSL compatibility layer, which a default build does not include. wolfSSL does not print certificates during a handshake on its own; the application has to call one of these functions on a certificate it did not create.
Affected Products and Versions
- Component:
src/x509.c,X509PrintName(), reached fromwolfSSL_X509_print_ex(),wolfSSL_X509_print()andwolfSSL_X509_print_fp(). - Required build:
OPENSSL_EXTRAwith BIO support andXSNPRINTF(src/x509.c:6847-6848,src/x509.c:7080).--enable-opensslextrais off by default (configure.ac:3314-3318);--enable-opensslalland several application-compatibility options turn it on (configure.ac:12708-12714). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same call with no escaping. Inv5.9.2-stablethe name printer has no control-character escaping under any flag. - Fixed on master. No wolfSSL release contains the fix.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
X509PrintName() writes the label, then the name, then a newline (src/x509.c:7859-7883):
if (wolfSSL_X509_NAME_print_ex(bio, name, 1, 0) <= 0) {
return WOLFSSL_FAILURE;
}
if (wolfSSL_BIO_write(bio, "\n", (int)XSTRLEN("\n")) <= 0) {
return WOLFSSL_FAILURE;
}
The last argument of wolfSSL_X509_NAME_print_ex() is the flag word. The name printer passes it to its escaping routine, where bytes below 0x20 and 0x7F are replaced only if WOLFSSL_ASN1_STRFLGS_ESC_CTRL is set (src/x509.c:15642-15645). With flags of 0 that branch is never taken. Every byte of the value is copied to the output (src/x509.c:15665-15667) and written to the BIO (src/x509.c:15834).
How the bytes arrive:
- The certificate parser reads each attribute of the issuer and subject. It accepts the usual string types (
wolfcrypt/src/asn.c:14906-14909) and does not look at the characters inside them. - Each value is added to the name object with its encoded length (
wolfcrypt/src/asn.c:15727-15732), and the entry stores the bytes unchanged (src/x509.c:14567-14587). - The names are attached to the
WOLFSSL_X509object (src/internal.c:15635-15649). wolfSSL_X509_print_ex()callsX509PrintName()for the issuer (src/x509.c:8099-8102) and the subject (src/x509.c:8113-8116).X509PrintName()prints the name with flags of 0.
Reachability and Preconditions
- The application calls
wolfSSL_X509_print,wolfSSL_X509_print_exorwolfSSL_X509_print_fpon a certificate from an untrusted source. No code in the library does this for a peer certificate. - The output goes somewhere line structure matters: a log file, syslog, an audit record, a terminal, or text that another program parses.
- The certificate does not need to be trusted. A peer certificate is handed to the application's verify callback as a
WOLFSSL_X509whether or not verification succeeded (src/internal.c:16320-16343), and it can print the certificate there. The example programs shipped with wolfSSL print the peer certificate this way when built withSHOW_CERTS(wolfssl/test.h:1432-1437). - A TLS peer, client or server, can therefore supply the certificate with no credentials. Certificates read from files or other channels are affected in the same way.
Impact
Confirmed from source: CR, LF and other control bytes in a subject or issuer attribute value reach the output BIO unchanged. The author of the certificate controls the text that follows the injected line break, up to the length of the value. The practical effect depends on where the application sends the dump. In a log it allows forged entries and can hide or split the real one. In a terminal, control bytes such as ESC are also passed through. Nothing in wolfSSL itself is corrupted, and the parsed certificate and its verification result are not changed by this issue.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
Fixed on master by commit b1a13054ea93064bf87e38f03daf7e30e698149a, part of PR 11682, merged 2026-10-15. The commit makes X509PrintName() pass WOLFSSL_ASN1_STRFLGS_ESC_CTRL, so a control byte is printed as a backslash followed by two hex digits. The same pull request adds that flag to WOLFSSL_XN_FLAG_ONELINE. The fix is on master only. No wolfSSL release contains it as of 2026-12-03; the newest release tag, v5.9.4-stable, does not. The tag rust/wolfssl-wolfcrypt/v3.0.0, which marks a version of the Rust wrapper, points at a master snapshot that includes it.
Until a release is available: print untrusted certificates into a memory BIO and escape or reject control characters before the text is written to a log or terminal, or do not print untrusted certificates.
The same helper is used for CRL issuers (BYTERAY-2026-0347) and certificate request subjects (BYTERAY-2026-0348); the commit closes all three. Subject alternative names are printed by different code, covered in BYTERAY-2026-0349 and BYTERAY-2026-0350.
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-10-07 — Pull request 11682 opened upstream.
- 2026-10-15 — Pull request 11682 merged to master.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.
References
X509PrintNameat the tested commit- Control-character branch of the name escaping routine at the tested commit
- wolfSSL pull request 11682
- Fix commit b1a13054ea93
- BYTERAY-2026-0347, CRL issuer name
- BYTERAY-2026-0348, certificate request subject
- BYTERAY-2026-0349, subjectAltName DNS, email and URI entries