Fix PKCS8_encrypt crash when pass is NULL with negative pass_len_in#3052
Merged
Fix PKCS8_encrypt crash when pass is NULL with negative pass_len_in#3052
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3052 +/- ##
==========================================
+ Coverage 78.38% 78.55% +0.17%
==========================================
Files 689 689
Lines 121131 121134 +3
Branches 16969 16975 +6
==========================================
+ Hits 94946 95155 +209
+ Misses 25291 25082 -209
- Partials 894 897 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
justsmth
reviewed
Mar 3, 2026
Comment on lines
+193
to
194
| } else if (pass_len_in < 0) { | ||
| pass_len = strlen(pass); |
Contributor
There was a problem hiding this comment.
The documentation is silent about this pass_len argument. We should add a sentence there about this logic.
justsmth
previously approved these changes
Mar 4, 2026
WillChilds-Klein
previously approved these changes
Mar 4, 2026
When pass is NULL and pass_len_in is negative, the cast to size_t wraps to a huge value, causing a NULL pointer dereference downstream in HMAC key setup. Handle pass==NULL first by setting pass_len=0, consistent with the documented empty byte string semantics for NULL passwords.
WillChilds-Klein
approved these changes
Mar 5, 2026
justsmth
approved these changes
Mar 5, 2026
WillChilds-Klein
pushed a commit
to WillChilds-Klein/aws-lc
that referenced
this pull request
Mar 11, 2026
…ws#3052) ### Description of changes: When pass is NULL and pass_len_in is negative, the cast to size_t wraps to a huge value, causing a NULL pointer dereference downstream in HMAC key setup. Handle pass==NULL first by setting pass_len=0, consistent with the documented empty byte string semantics for NULL passwords. ### 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
…ws#3052) ### Description of changes: When pass is NULL and pass_len_in is negative, the cast to size_t wraps to a huge value, causing a NULL pointer dereference downstream in HMAC key setup. Handle pass==NULL first by setting pass_len=0, consistent with the documented empty byte string semantics for NULL passwords. ### 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:
When pass is NULL and pass_len_in is negative, the cast to size_t wraps
to a huge value, causing a NULL pointer dereference downstream in HMAC
key setup. Handle pass==NULL first by setting pass_len=0, consistent
with the documented empty byte string semantics for NULL passwords.
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.