Skip to content

Fix off-by-one OOB NUL write in GetCertName (classic ASN parser)#10952

Open
embhorn wants to merge 1 commit into
wolfSSL:masterfrom
embhorn:zd22171
Open

Fix off-by-one OOB NUL write in GetCertName (classic ASN parser)#10952
embhorn wants to merge 1 commit into
wolfSSL:masterfrom
embhorn:zd22171

Conversation

@embhorn

@embhorn embhorn commented Jul 20, 2026

Copy link
Copy Markdown
Member

Description

GetCertName() in the classic ASN.1 parser (asn_orig.c) wrote a 1-byte out-of-bounds NUL terminator when a certificate's Subject or Issuer DN exactly filled the WC_ASN_NAME_MAX-byte cert->subject / cert->issuer buffer.

Fixes zd22171

Testing

test_ParseCert_dnBufferBoundary, which builds certificates whose second RDN lands the name index on exactly the buffer cap.

Checklist

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

@embhorn embhorn self-assigned this Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 17:41

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.

Pull request overview

Fixes a one-byte out-of-bounds NUL terminator write in the classic ASN.1 parser’s GetCertName() when a Subject/Issuer DN exactly fills the WC_ASN_NAME_MAX buffer, by tightening “too big” checks so exact-fit (no room for '\0') is rejected.

Changes:

  • Update GetCertName() buffer-capacity comparisons from > to >= to ensure space remains for the terminating NUL.
  • Add a regression test that constructs certificates whose second RDN hits the DN buffer boundary (exact cap vs. one byte under), covering multiple attribute-prefix branches.
  • Register the new test in the ASN API test declarations/group list.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
wolfcrypt/src/asn_orig.c Tightens DN buffer bounds checks to prevent an exact-fill case from writing the NUL terminator out of bounds.
tests/api/test_asn.h Declares and registers the new DN boundary regression test.
tests/api/test_asn.c Adds test_ParseCert_dnBufferBoundary() to validate boundary behavior across relevant DN attribute branches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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 #10952

Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src

No new issues found in the changed files. ✅

@embhorn

embhorn commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

retest this please

@embhorn embhorn assigned wolfSSL-Bot and unassigned embhorn Jul 22, 2026
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.

4 participants