← ALL ADVISORIES

MEDIUM BYTERAY-2026-0352Patched

wolfSSL — CR/LF Injection in Certificate Request Attributes Printed by wolfSSL_X509_REQ_print

wolfSSL_X509_REQ_print writes the attributes of a certificate signing request, such as the challenge password and unstructured name, with a plain string format and no escaping. An attribute value that contains CR or LF adds lines chosen by the submitter to the printed text. The value is limited to about 49 bytes. Only builds with the full OpenSSL compatibility layer and certificate generation are affected.

Advisory
BYTERAY-2026-0352
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_ALL, WOLFSSL_CERT_GEN and WOLFSSL_CERT_REQ whose application prints submitted certificate requests with wolfSSL_X509_REQ_print
Fixed in
Master commit 48a0411bcb135d5f39a609ef02884411e89cefe3 (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

The text dump of a certificate signing request ends with an Attributes: section. Each attribute is printed on its own line as a name, padding, a colon and the value. The value is inserted with %s.

Attribute values are taken from the request as submitted. The decoder checks that each is a string type and nothing more. A value that contains CR or LF therefore breaks the attribute line, and the rest of the value appears as a new line in the dump.

The line buffer is 80 bytes, which leaves roughly 49 bytes for the value. That is enough for a forged line. The affected path needs four build options that a default build does not set, and the application has to print requests it received from someone else.

Affected Products and Versions

  • Component: src/x509.c, X509PrintReqAttributes(), called by wolfSSL_X509_REQ_print().
  • Required build: OPENSSL_EXTRA with BIO support and XSNPRINTF, and WOLFSSL_CERT_REQ for the print code (src/x509.c:7918); OPENSSL_ALL and WOLFSSL_CERT_GEN for the attribute list to be filled when a request is decoded (src/internal.c:15207, src/internal.c:15242). All are off by default (configure.ac:3294-3298, configure.ac:3314-3318, configure.ac:5709-5713, configure.ac:5723-5727).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The v5.9.2-stable and v5.9.4-stable tags contain the same format call.
  • Fixed on master. No wolfSSL release contains the fix.
  • A default ./configure build does not include this code. Earlier releases were not checked.

Technical Details

For each attribute, X509PrintReqAttributes() fetches the string data and formats the line (src/x509.c:7955-7967):

            if ((scratchLen = XSNPRINTF(scratch, MAX_WIDTH,
                          "%*s%s%*s:%s\n", indent+4, "",
                          lName, (NAME_SZ/4)-lNameSz, "", data))
                >= MAX_WIDTH)
            {
                return WOLFSSL_FAILURE;
            }

The buffer is written to the BIO (src/x509.c:7968). data is the attribute value and is not examined. How the bytes arrive:

  1. The request decoder accepts a PrintableString, IA5String or UTF8String for the content type, challenge password, serial number and unstructured name attributes and records a pointer and a length (wolfcrypt/src/asn.c:23904-23906, wolfcrypt/src/asn.c:23930-24003). The characters are not checked.
  2. CopyREQAttributes() passes each recorded value to wolfSSL_X509_REQ_add1_attr_by_NID() (src/internal.c:15199-15306).
  3. That function stores the bytes in a string object and adds it to the request's attribute list (src/x509.c:17398-17418, src/x509.c:17475-17477).
  4. wolfSSL_X509_REQ_print() calls X509PrintReqAttributes() (src/x509.c:8030), which prints each stored value with %s.

Limits found in the source: if the formatted line reaches 80 bytes the print fails, which caps the value at about 49 bytes with the indent used here. %s stops at a NUL byte. A serial number attribute must be shorter than 32 bytes (src/x509.c:17453-17457). None of these prevents a short forged line.

Reachability and Preconditions

  • The application receives certificate requests from parties it does not fully trust and calls wolfSSL_X509_REQ_print on them. Typical callers are 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. Attributes are part of the request the submitter writes.
  • In a build without OPENSSL_ALL or without WOLFSSL_CERT_GEN, a decoded request has an empty attribute list and nothing is printed in this section.

Impact

Confirmed from source: CR, LF and other control bytes in a request attribute value reach the output BIO unchanged, and the submitter controls up to about 49 bytes including the injected line break. The effect is limited to the printed text: forged or split lines in whatever consumes the dump, and control bytes such as ESC passed 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 48a0411bcb135d5f39a609ef02884411e89cefe3, part of PR 11682, merged 2026-10-15. The commit stops formatting the value with %s and prints it through the escaping helper introduced in the same pull request, so a control byte is printed as a backslash followed by two hex digits. 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.

The subject line of the same dump has a separate defect and a separate fix commit; see BYTERAY-2026-0348. Certificate dumps are covered in BYTERAY-2026-0351.

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