Skip to content

Fix PKCS8_encrypt crash when pass is NULL with negative pass_len_in#3052

Merged
geedo0 merged 1 commit intoaws:mainfrom
geedo0:f28
Mar 6, 2026
Merged

Fix PKCS8_encrypt crash when pass is NULL with negative pass_len_in#3052
geedo0 merged 1 commit intoaws:mainfrom
geedo0:f28

Conversation

@geedo0
Copy link
Copy Markdown
Contributor

@geedo0 geedo0 commented Feb 27, 2026

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.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.55%. Comparing base (fb0c415) to head (ee190a6).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +193 to 194
} else if (pass_len_in < 0) {
pass_len = strlen(pass);
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.

The documentation is silent about this pass_len argument. We should add a sentence there about this logic.

@geedo0 geedo0 marked this pull request as ready for review March 4, 2026 13:39
@geedo0 geedo0 requested a review from a team as a code owner March 4, 2026 13:39
justsmth
justsmth 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.
@geedo0 geedo0 enabled auto-merge (squash) March 5, 2026 21:59
@geedo0 geedo0 merged commit 092453f into aws:main Mar 6, 2026
530 of 551 checks passed
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.
@geedo0 geedo0 deleted the f28 branch March 27, 2026 19:28
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