Issue: Missing Signature Length Validation in ltc_pkcs_1_pss_decode_mgf1 #802
Labels
No labels
bug
duplicate
enhancement
feature
help wanted
improve API
invalid
needs documentation
not-planned
rtfm
stale
support
wishlist
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libtom/libtomcrypt#802
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
ltc_pkcs_1_pss_decode_mgf1must ensure thatsiglenis exactly equal to the calculatedmodulus_len.Later in the function,
(modulus_len - hLen - 1) + hLen = modulus_len - 1bytes are copied fromsigstarting atoffset 0. Without an explicit length check, a too-short signature can therefore cause an out-of-bounds read.The signature originates from the peer's certificate and must be treated as untrusted input. While the current caller,
rsa_verify_hash_v2, happens to satisfy this requirement through a non-obvious calculation involvingmodulus_bitlen%8, the validation should be enforced directly inltc_pkcs_1_pss_decode_mgf1.Affected Code
src/pk/pkcs1/pkcs_1_pss_decode.c:53
Suggested Fix