wolfSSL — CR/LF Injection in Certificate Request Subject Printed by wolfSSL_X509_REQ_print
wolfSSL_X509_REQ_print writes the subject of a certificate signing request to the output without escaping control characters. A request whose subject contains CR or LF adds lines chosen by the submitter to the printed text. Services that print or log requests they receive, such as enrolment front ends, are affected.
- Advisory
- BYTERAY-2026-0348
- 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 and WOLFSSL_CERT_REQ whose application prints submitted certificate requests with wolfSSL_X509_REQ_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_REQ_print produces a text dump of a PKCS #10 certificate signing request. The Subject: line is written by the helper that prints certificate names, and that helper asks the name printer for no escaping.
The subject is whatever the submitter put in the request. A value that contains CR or LF is written unchanged, so the dump gains extra lines with content the submitter chose. In a log or a review screen those lines look like the application's own output.
A request is by nature untrusted input: the party who needs a certificate writes it. The affected function is in the OpenSSL compatibility layer and requires certificate request support, neither of which is in a default build. The application has to call the print function; the library does not.
Affected Products and Versions
- Component:
src/x509.c,wolfSSL_X509_REQ_print(), throughX509PrintName(). - Required build:
OPENSSL_EXTRAwith BIO support andXSNPRINTF, plusWOLFSSL_CERT_REQ(src/x509.c:6847-6848,src/x509.c:7918).--enable-opensslextraand--enable-certreqare off by default (configure.ac:3314-3318,configure.ac:5723-5727). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same code path. - Fixed on master. No wolfSSL release contains the fix.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
The print function hands the subject to X509PrintName() (src/x509.c:8014-8017):
if (X509PrintName(bio, wolfSSL_X509_get_subject_name(x509), subjType, 8)
!= WOLFSSL_SUCCESS) {
return WOLFSSL_FAILURE;
}
X509PrintName() calls wolfSSL_X509_NAME_print_ex(bio, name, 1, 0) and then writes a newline (src/x509.c:7875-7880). The fourth argument is the flag word. The escaping routine replaces control characters only when WOLFSSL_ASN1_STRFLGS_ESC_CTRL is set (src/x509.c:15642-15645). With flags of 0 every byte of each value goes to the BIO as it is.
How the bytes arrive:
wolfSSL_X509_REQ_d2i()and the readers built on it decode the request as a certificate request (src/x509.c:4285-4290,src/x509.c:4221,src/x509.c:4241).- The request subject goes through the same name parser as a certificate subject (
wolfcrypt/src/asn.c:23768-23773). The parser stores each attribute value with its encoded length and does not inspect the characters (wolfcrypt/src/asn.c:15727-15732). - The decoded name is attached to the
WOLFSSL_X509object that represents the request (src/internal.c:15643-15649). wolfSSL_X509_REQ_print()prints that name with flags of 0.
Reachability and Preconditions
- The application receives certificate requests from parties it does not fully trust and calls
wolfSSL_X509_REQ_printon them. Typical callers are registration or enrolment services and tools that show a request to an operator before signing. - The output goes somewhere line structure matters: a log, an audit record, a terminal, or text that another program parses.
- The submitter needs no special position. Writing the subject of a request is the normal role of the requester.
- Applications that only parse or sign requests and never print them are not affected.
Impact
Confirmed from source: CR, LF and other control bytes in a request subject attribute reach the output BIO unchanged, and the submitter controls the text after the injected line break. The effect is limited to the printed text. It allows forged or split lines in whatever consumes the dump, such as an enrolment log. Control bytes such as ESC also pass through to a terminal. The request object and any certificate later issued from it 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 in the subject is printed as a backslash followed by two hex digits. The pull request also adds a request print test for this case. 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 requests into a memory BIO and escape or reject control characters before the text reaches a log or terminal, or reject requests whose subject contains control characters before printing.
This is the same helper and the same commit as BYTERAY-2026-0351 (certificate subject and issuer) and BYTERAY-2026-0347 (CRL issuer). The attribute section of the same dump has a separate defect and a separate fix commit; see BYTERAY-2026-0352.
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.