Fix PKCS12_verify_mac OOB read with invalid password_len#3051
Merged
Fix PKCS12_verify_mac OOB read with invalid password_len#3051
Conversation
Reject negative password_len values (other than -1) early in PKCS12_verify_mac before they are used as an array index or cast to size_t for OPENSSL_memchr. Update the public header comment to clarify that -1 means the password is a NUL-terminated C string.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3051 +/- ##
=======================================
Coverage 78.34% 78.35%
=======================================
Files 689 689
Lines 121025 121027 +2
Branches 16964 16967 +3
=======================================
+ Hits 94822 94830 +8
+ Misses 25306 25302 -4
+ Partials 897 895 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
justsmth
approved these changes
Mar 3, 2026
WillChilds-Klein
approved these changes
Mar 4, 2026
| // |password[password_len]| must be zero and no other NUL bytes may appear in | ||
| // |NULL| and zero, respectively, or else |password_len| may be -1 to indicate | ||
| // that |password| is a NUL-terminated C string whose length is determined via | ||
| // |strlen|, or else |password_len| must be non-negative, |
Contributor
There was a problem hiding this comment.
note for reviewers, looks like strlen is called a bit further down the callstack in PKCS12_get_key_and_certs
Contributor
There was a problem hiding this comment.
not your change, but this is such an odd API contract... it enforces that 1/ password must be NULL-terminated and 2/ password_len == -1 indicates that it's NULL-terminated. then eventually calls strlen unconditionally.
WillChilds-Klein
pushed a commit
to WillChilds-Klein/aws-lc
that referenced
this pull request
Mar 11, 2026
### Description of changes: Reject negative password_len values (other than -1) early in PKCS12_verify_mac before they are used as an array index or cast to size_t for OPENSSL_memchr. Update the public header comment to clarify that -1 means the password is a NUL-terminated C string. ### Call-outs: N/A ### Testing: How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer? CI By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
nebeid
pushed a commit
to nebeid/aws-lc
that referenced
this pull request
Mar 23, 2026
### Description of changes: Reject negative password_len values (other than -1) early in PKCS12_verify_mac before they are used as an array index or cast to size_t for OPENSSL_memchr. Update the public header comment to clarify that -1 means the password is a NUL-terminated C string. ### Call-outs: N/A ### Testing: How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer? CI By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
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 of changes:
Reject negative password_len values (other than -1) early in
PKCS12_verify_mac before they are used as an array index or cast
to size_t for OPENSSL_memchr. Update the public header comment to
clarify that -1 means the password is a NUL-terminated C string.
Call-outs:
N/A
Testing:
How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?
CI
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.