ltc_pkcs_1_v1_5_decode accepts input shorter than the expected modulus length (msglen < modulus_len), but subsequently accesses the input as if it were modulus_len bytes long. This may result in out-of-bounds reads when processing truncated input.
According to PKCS#1 v1.5 (RFC 8017), the encoded message must be exactly the length of the RSA modulus. Rejecting inputs whose length differs from modulus_len prevents truncated inputs from being processed and avoids out-of-bounds reads.
Affected Code
Location: Location: src/pk/pkcs1/pkcs_1_v1_5_decode.c:42
if ((msglen > modulus_len) || (modulus_len < 11)) {
return CRYPT_PK_INVALID_SIZE;
}
Expected Behavior
if ((msglen != modulus_len) || (modulus_len < 11)) {
return CRYPT_PK_INVALID_SIZE;
}
ltc_pkcs_1_v1_5_decodeaccepts input shorter than the expected modulus length (msglen < modulus_len), but subsequently accesses the input as if it weremodulus_lenbytes long. This may result in out-of-bounds reads when processing truncated input.According to PKCS#1 v1.5 (RFC 8017), the encoded message must be exactly the length of the RSA modulus. Rejecting inputs whose length differs from
modulus_lenprevents truncated inputs from being processed and avoids out-of-bounds reads.Affected Code
Location: Location: src/pk/pkcs1/pkcs_1_v1_5_decode.c:42
Expected Behavior