wolfSSL — CR/LF Injection in Attribute Certificate Directory Names Printed by wolfSSL_X509_ACERT_print
The text dump of an X.509 attribute certificate prints the directory names of the holder and the issuer by copying their attribute values to the output unchanged. An attribute certificate whose holder or issuer name contains CR or LF adds lines of its author's choosing to the dump. Only builds with attribute certificate support and applications that print untrusted attribute certificates are affected.
- Advisory
- BYTERAY-2026-0346
- 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 --enable-acert and OPENSSL_EXTRA whose application prints untrusted attribute certificates with wolfSSL_X509_ACERT_print
- Fixed in
- Master commit ca5806224df0b36af17f869948a07bf759b61bc3 (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 can parse and print X.509 attribute certificates when built with --enable-acert. wolfSSL_X509_ACERT_print() writes a text dump that includes the holder's name, the holder's issuer name and the name of the attribute certificate issuer. These are directory names taken from the attribute certificate.
The routine that formats a directory name copies the country, organization, organizational unit and common name values into the output line without looking at their bytes. A value that contains CR or LF breaks the line, and the text after the break is whatever the author of the attribute certificate put there. In a log or audit trail it reads as a separate entry. The loader does not check the signature of the attribute certificate, so the content does not have to come from a trusted issuer. Attribute certificate support is off by default. wolfSSL has no protocol code that receives attribute certificates; the application supplies them and decides whether to print them.
Affected Products and Versions
- Component:
src/x509.c,wolfSSL_X509_ACERT_print(),X509_print_name_entry()andX509PrintDirType(). - Required build:
WOLFSSL_ACERT(--enable-acert, default disabled,configure.ac:5702-5706) together withOPENSSL_EXTRA, BIO support andXSNPRINTF(src/x509.c:6847-6848,src/x509.c:7080,src/x509.c:8145). Directory names are decoded only whenIGNORE_NAME_CONSTRAINTSis not defined (wolfcrypt/src/asn.c:41066-41084). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same print calls and the same unescaped copy. - Fixed on master. No wolfSSL release contains the fix.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
wolfSSL_X509_ACERT_print() prints each of the three name lists with the same helper (src/x509.c:8262, src/x509.c:8275, src/x509.c:8293). For a directory name the helper calls X509PrintDirType() (src/x509.c:7024-7025), writes the result to the BIO (src/x509.c:7064-7065) and ends the list with a newline of its own (src/x509.c:7073).
X509PrintDirType() searches the encoded name for the object identifiers of C, O, OU and CN (src/x509.c:6863-6869), accepts a PrintableString, IA5String or UTF8String value (src/x509.c:6930-6936) and copies it (src/x509.c:6955-6962):
if (fld_len > bytes_left) {
/* Not enough space left. */
break;
}
XMEMCPY(dst, &src[i], fld_len);
i += fld_len;
dst += fld_len;
No byte of the value is examined between the decoder and this copy.
How the value arrives:
- The application loads an attribute certificate with
wolfSSL_X509_ACERT_load_certificate_buffer()(src/x509.c:17939-18025) or withwolfSSL_PEM_read_bio_X509_ACERT(), which calls it (src/x509.c:13855-13876). The loader parses the object and does not verify the signature; verification is a separate call (src/x509.c:17881). - The decoder stores the contents of each directoryName in the holder and issuer fields with its encoded length (
wolfcrypt/src/asn.c:41068-41084). - The three lists are copied to the
WOLFSSL_X509_ACERTobject. The copy keeps directory names only (src/internal.c:15903-15915, filter atsrc/internal.c:15040-15041), so DNS, email and URI names in these fields are never printed. - The application calls
wolfSSL_X509_ACERT_print(), and the values are copied to the output as shown above.
Reachability and Preconditions
- The library is built with attribute certificate support and the OpenSSL compatibility layer.
- The application loads an attribute certificate from a source an attacker can influence and prints it with
wolfSSL_X509_ACERT_print(). wolfSSL does not receive attribute certificates in TLS or any other protocol it implements, so this depends entirely on how the application obtains them. - The output goes to a log, terminal, audit record or other place where line structure carries meaning.
- The attacker does not need a valid signature on the attribute certificate unless the application verifies it before printing.
Impact
Confirmed from source: CR, LF and other control bytes in a C, O, OU or CN value of a holder or issuer directory name are written to the output BIO. Each entry is assembled in an 80-byte buffer that also holds the attribute labels; a value that does not fit is left out (src/x509.c:6955-6958), and a NUL byte ends the entry. The injected text is therefore short: enough for a forged line, not for long content. Names of other kinds in these fields are not printed and cannot be used. Parsing and verification of the attribute certificate are not affected.
Not verified: the effect on any particular application or log consumer.
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 ca5806224df0b36af17f869948a07bf759b61bc3, part of PR 11682, merged 2026-10-15. The commit makes X509PrintDirType() pass each attribute value through an escaping helper that prints a control byte as a backslash followed by two hex digits. The same pull request adds a test that prints an attribute certificate with control characters in the holder name. The fix is on master only. No wolfSSL release contains it as of 2026-12-03.
Until a release is available: verify an attribute certificate before printing it, print to a memory BIO and escape or reject control characters before the text reaches a log or terminal, or do not print untrusted attribute certificates.
The same routine prints directoryName alternative names of ordinary certificates; that entry point is BYTERAY-2026-0350, closed by the same commit. DNS, email and URI alternative names are BYTERAY-2026-0349.
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
X509PrintDirTypeat the tested commit- Name printing in
wolfSSL_X509_ACERT_printat the tested commit - Name list copy for attribute certificates at the tested commit
- wolfSSL pull request 11682
- Fix commit ca5806224df0
- BYTERAY-2026-0350, directoryName alternative names in the certificate text dump
- BYTERAY-2026-0349, DNS, email and URI alternative names in the certificate text dump
- CWE-144: Improper Neutralization of Line Delimiters