Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3079 +/- ##
==========================================
+ Coverage 78.36% 78.38% +0.01%
==========================================
Files 689 689
Lines 121144 121154 +10
Branches 16973 16974 +1
==========================================
+ Hits 94935 94961 +26
+ Misses 25314 25298 -16
Partials 895 895 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nebeid
approved these changes
Mar 10, 2026
samuel40791765
approved these changes
Mar 11, 2026
WillChilds-Klein
pushed a commit
to WillChilds-Klein/aws-lc
that referenced
this pull request
Mar 11, 2026
### Description of changes: - **Use-after-free on BER input:** `CBS_asn1_ber_to_der` may allocate a DER conversion buffer (`storage`) that backs all subsequent CBS parsing. The function freed it immediately after the call, but the CBS values derived from it were still in use. Moved the free to the cleanup label, matching `PKCS12_get_key_and_certs` and `PKCS12_handle_sequence`. - **Dangling `ber_bytes` on `CBB_finish` failure:** The old `p12->ber_bytes` was freed before `CBB_finish`, so a failure left `p12` with a dangling pointer. Now we null out the pointer and zero the length immediately after freeing, so `p12` stays in a safe (empty) state on failure. - **Negative `salt_len` / `password_len` not rejected:** Both are signed `int` but flow into `size_t` parameters downstream. Negative values now return early. `password_len == -1` is normalized via `strlen` to match the convention in `PKCS12_verify_mac`. ### Call-outs: The `password_len == -1` (use strlen) convention is already supported by `PKCS12_verify_mac`, which this function calls at the end. Without the normalization, the MAC generation and verification would use different password lengths and the function would always fail for that input. ### Testing: All 16 existing `PKCS12Test.*` tests pass, including `PKCS12Test.SetMac`. 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:
Use-after-free on BER input:
CBS_asn1_ber_to_dermay allocate a DER conversion buffer (storage) that backs all subsequent CBS parsing. The function freed it immediately after the call, but the CBS values derived from it were still in use. Moved the free to the cleanup label, matchingPKCS12_get_key_and_certsandPKCS12_handle_sequence.Dangling
ber_bytesonCBB_finishfailure: The oldp12->ber_byteswas freed beforeCBB_finish, so a failure leftp12with a dangling pointer. Now we null out the pointer and zero the length immediately after freeing, sop12stays in a safe (empty) state on failure.Negative
salt_len/password_lennot rejected: Both are signedintbut flow intosize_tparameters downstream. Negative values now return early.password_len == -1is normalized viastrlento match the convention inPKCS12_verify_mac.Call-outs:
The
password_len == -1(use strlen) convention is already supported byPKCS12_verify_mac, which this function calls at the end. Without the normalization, the MAC generation and verification would use different password lengths and the function would always fail for that input.Testing:
All 16 existing
PKCS12Test.*tests pass, includingPKCS12Test.SetMac.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.