Skip to content

Commit 4e46730

Browse files
committed
Bug fix: GCM - fix potential buffer overflow
If the caller provides a too long tag length value to GCM decrypt, GCM writes zeros beyond the buffer limits for the newly calculated tags. Reported-by: Conner Webber Signed-off-by: Stephan Mueller <[email protected]>
1 parent fa8778a commit 4e46730

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎CHANGES.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Changes 1.9.0-prerelease
4747

4848
* bug fix: lc_memcmp_secure returns negative error on string mismatch to align its return code with the rest of leancrypto (reported by Conner Webber)
4949

50+
* bug fix: GCM contains a buffer overflow potentially writing zeros beyond a caller buffer upon GCM decrypt with an oversized tag length
51+
5052
Changes 1.8.0
5153
* X.509: provide a common automated serial number generator which is the 20 leftmost bytes of the SHA3-256 hash of the certificate DER blob with the serial number being 20 bytes of 0xff and the signature part equally a range of 0xff bytes
5254

‎aead/src/gcm.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,9 @@ static int gcm_dec_final(void *state, const uint8_t *tag, size_t taglen)
897897
{
898898
/* the tag generated and returned by decryption */
899899
uint8_t check_tag[AES_BLOCKSIZE] __align(8);
900-
int ret;
900+
int ret = 0;
901+
902+
CKRET(taglen > sizeof(check_tag), -EINVAL);
901903

902904
CKINT(gcm_enc_final(state, check_tag, taglen));
903905

0 commit comments

Comments
 (0)