Skip to content

[FIPS 4.x] Address Reported Bug Findings - #3006

Merged
skmcgrail merged 6 commits into
aws:fips-2025-09-12from
skmcgrail:fips-2025-09-12-patches
Feb 18, 2026
Merged

skmcgrail merged 6 commits into
aws:fips-2025-09-12from
skmcgrail:fips-2025-09-12-patches

Conversation

@skmcgrail

Copy link
Copy Markdown
Member

This PR contains 6 bug fixes for various issues in AWS-LC. We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting these issues.

Commits

1. evp: fix DSA keygen error-path UAF/double-free

pkey_dsa_keygen() assigns a freshly allocated DSA into EVP_PKEY before EVP_PKEY_copy_parameters(), then frees the DSA on failure, leaving pkey holding a dangling pointer. This fix avoids freeing after ownership transfer by nulling the local pointer and clearing/freeing the pkey-held key on error.

2. 1-byte OOB read in EVP_PKEY_asn1_find_str length calculation

Fixes an off-by-one out-of-bounds read in the EVP_PKEY_asn1_find_str length calculation.

3. pkcs8: cap ciphertext length before allocating in pkcs8_pbe_decrypt

pkcs8_pbe_decrypt() allocates OPENSSL_malloc(in_len) where in_len is influenced by ASN.1 OCTET STRING lengths. The existing INT_MAX check only guards EVP_DecryptUpdate's int parameter and occurs after the allocation. This fix caps the ciphertext length before allocating.

4. evp: disable EVP_PKEY_derive for KEM method

EVP_PKEY_kem_pkey_meth incorrectly assigned out->derive to pkey_hkdf_derive, causing ctx->data type confusion (KEM_PKEY_CTX vs HKDF_PKEY_CTX) when callers invoke EVP_PKEY_derive on a KEM context. This fix sets out->derive to NULL so the operation fails as unsupported.

5. Reject zero-sized digests in HKDF EVP_PKEY

Rejects digests with EVP_MD_size <= 0 when configuring HKDF and when deriving, preventing divide-by-zero in HKDF_expand if an XOF digest is selected.

6. Reject XOF digests in DH_compute_key_hashed

DH_compute_key_hashed passes an uninitialized out_len to EVP_Digest. For XOF digests, EVP_DigestFinalXOF interprets *out_size as an input length, which can cause an out-of-bounds write to the caller-provided buffer. This fix rejects XOF digests and initializes out_len to the fixed digest size.

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.

skmcgrail and others added 6 commits February 18, 2026 00:51
pkey_dsa_keygen() assigns a freshly allocated DSA into EVP_PKEY before
EVP_PKEY_copy_parameters(), then frees the DSA on failure, leaving pkey
holding a dangling pointer. Avoid freeing after ownership transfer by
nulling the local pointer and clearing/freeing the pkey-held key on error.
Also use DSA_free() for DSA objects.

We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting this issue.

(cherry picked from commit cf2e09f)
We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting this issue.

(cherry picked from commit 921c646)
pkcs8_pbe_decrypt() allocates OPENSSL_malloc(in_len) where in_len is derived
from attacker-influenced ASN.1 OCTET STRING lengths. The existing INT_MAX
check only guards EVP_DecryptUpdateโ€™s int parameter and occurs after the
allocation.

We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting this issue.

(cherry picked from commit e17506c)
EVP_PKEY_kem_pkey_meth incorrectly assigned out->derive to pkey_hkdf_derive,
causing ctx->data type confusion (KEM_PKEY_CTX vs HKDF_PKEY_CTX) when callers
invoke EVP_PKEY_derive on a KEM context. Set out->derive to NULL so the
operation fails as unsupported rather than dispatching into HKDF.

We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting this issue.

(cherry picked from commit dcd1690)
Reject digests with EVP_MD_size <= 0 when configuring HKDF and when deriving,
preventing divide-by-zero in HKDF_expand if an XOF digest is selected.

We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting this issue.

(cherry picked from commit 8a43348)
DH_compute_key_hashed passes an uninitialized out_len to EVP_Digest.
For XOF digests, EVP_DigestFinalXOF interprets *out_size as an input length,
which can cause an out-of-bounds write to the caller-provided buffer.
Reject XOF digests and initialize out_len to the fixed digest size.

We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting this issue.

(cherry picked from commit 110f184)
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

โŒ Patch coverage is 84.61538% with 6 lines in your changes missing coverage. Please review.
โœ… Project coverage is 78.70%. Comparing base (1276fc7) to head (f9ba277).

Files with missing lines Patch % Lines
crypto/evp_extra/p_dsa.c 57.14% 3 Missing โš ๏ธ
crypto/fipsmodule/evp/p_hkdf.c 71.42% 2 Missing โš ๏ธ
crypto/pkcs8/pkcs8.c 75.00% 1 Missing โš ๏ธ
Additional details and impacted files
@@                 Coverage Diff                 @@
##           fips-2025-09-12    #3006      +/-   ##
===================================================
+ Coverage            78.67%   78.70%   +0.02%     
===================================================
  Files                  667      667              
  Lines               113027   113044      +17     
  Branches             16068    16055      -13     
===================================================
+ Hits                 88929    88971      +42     
+ Misses               23322    23297      -25     
  Partials               776      776              

โ˜” 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.

@skmcgrail
skmcgrail merged commit 2c1caef into aws:fips-2025-09-12 Feb 18, 2026
128 of 152 checks passed
@skmcgrail
skmcgrail deleted the fips-2025-09-12-patches branch February 18, 2026 17:46

This branch was successfully deployed

No deployments
auto-approve โ€” f9ba2779 Deployed Feb 18, 2026 by skmcgrail via android-debug-static #154
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