Fix off-by-one OOB NUL write in GetCertName (classic ASN parser)#10952
Open
embhorn wants to merge 1 commit into
Open
Fix off-by-one OOB NUL write in GetCertName (classic ASN parser)#10952embhorn wants to merge 1 commit into
embhorn wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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. ✅
Member
Author
|
retest this please |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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