Skip to content

Fix read length in ASN1_STRING_print_ex/to_UTF8. Refactor freeing logic in wolfSSL_X509_get0_extensions. Only read GENERAL_NAME types with strings in wolfSSL_X509V3_EXT_print. Properly handle NULLs inside of DNs in X509_NAME_oneline. - #11627

Open
kareem-wolfssl wants to merge 6 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd22448_x509

Conversation

@kareem-wolfssl

Copy link
Copy Markdown
Contributor

Description

Partially fixes zd#22448

Testing

Built in + added tests, reproducers

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m0plus

  • FLASH: .text +24 B (+0.0%, 70,427 B / 262,144 B, total: 27% used)

gcc-arm-cortex-m3

  • FLASH: .text +108 B (+0.1%, 130,717 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4

  • FLASH: .text +64 B (+0.0%, 209,884 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .text +64 B (+0.1%, 72,951 B / 262,144 B, total: 28% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +256 B (+0.1%, 194,200 B / 1,048,576 B, total: 19% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +448 B (+0.1%, 795,052 B / 1,048,576 B, total: 76% used)
  • RAM: .bss -4 B (-0.0%, 133,820 B / 262,144 B, total: 51% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +64 B (+0.0%, 223,488 B / 262,144 B, total: 85% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +320 B (+0.1%, 311,588 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +256 B (+0.1%, 342,936 B / 1,048,576 B, total: 33% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +128 B (+0.1%, 131,473 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +192 B (+0.1%, 249,102 B / 262,144 B, total: 95% used)

gcc-arm-cortex-m7

  • FLASH: .text +64 B (+0.0%, 209,884 B / 262,144 B, total: 80% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +256 B (+0.1%, 312,484 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +192 B (+0.1%, 249,166 B / 262,144 B, total: 95% used)

stm32-sim-stm32h753

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The NUL escape remains ambiguous with literal \x00 input, allowing distinct names to compare equal.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Improves OpenSSL compatibility and safety for ASN.1 strings, X.509 extensions, general names, and embedded NULs in distinguished names.

Changes:

  • Uses explicit ASN.1 lengths and ensures UTF-8 output termination.
  • Stabilizes cached extension stacks and safely handles GENERAL_NAME variants.
  • Escapes embedded NULs in one-line X.509 names and adds regression tests.
File Description
wolfssl/​openssl/​x509.h Aligns one-line name flags with OpenSSL.
src/​x509.c Updates extension caching, parsing, printing, and DN rendering.
src/​ssl_asn1.c Fixes length-based ASN.1 copying and printing.
tests/​api/​test_ossl_asn1.c Updates escaped-string length coverage.
tests/​api/​test_ossl_x509_ext.c Tests extension stability and GENERAL_NAME safety.
tests/​api/​test_ossl_x509_ext.h Registers the extension stability test.
tests/​api/​test_ossl_x509_name.c Tests embedded-NUL distinguished names.
tests/​api/​test_ossl_x509_name.h Registers the embedded-NUL test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/x509.c Resolved
@kareem-wolfssl
kareem-wolfssl force-pushed the zd22448_x509 branch 3 times, most recently from 45803a0 to e2265a7 Compare October 20, 2026 22:55
… in wolfSSL_X509_set_ext.

Thanks to Anthropic for the report.
…ing the extension stack unless it is NULL.

Allow non critical extensions and extensions with zero-length OCTET STRING to match the core DER parser behavior.
Thanks to Anthropic for the report.
@padelsbach

padelsbach commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

@kareem-wolfssl, while reviewing #11446, I saw that this PR touches similar logic. I think we should merge that one first, then roll the new NUL check into X509CertEscapeName

I had mistakenly posted this comment on a different PR earlier, my bad.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Extension-generation failures can permanently cache incomplete results, while XN_FLAG_ONELINE incorrectly escapes UTF-8 bytes, causing a compatibility regression.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/x509.c
Comment on lines +427 to 429
if (x509->ext_sk_full == NULL) {
x509->ext_sk_full = generateExtStack(x);
}
Comment thread wolfssl/openssl/x509.h
WOLFSSL_XN_FLAG_FN_LN | \
WOLFSSL_XN_FLAG_FN_ALIGN)
#define WOLFSSL_XN_FLAG_ONELINE (WOLFSSL_ASN1_STRFLGS_ESC_CTRL | \
WOLFSSL_ASN1_STRFLGS_RFC2253 | \

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #11627

Scan targets checked: wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_ossl_x509_ext.h, tests/api/test_ossl_x509_name.h
Coverage: 3 of 6 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_ossl_x509_ext.c, tests/api/test_ossl_x509_name.c, wolfssl/openssl/x509.h

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants