From: Thomas Pornin Date: Mon, 6 Apr 2026 13:40:05 +0000 (-0400) Subject: Fixed bug in handling incoming records with invalid length (impacted CBC encryption... X-Git-Url: https://www.bearssl.org/gitweb//home/git/?a=commitdiff_plain;h=7bea48e5e850ab4cafbe68d3765cdaba13a86d6f;p=BearSSL Fixed bug in handling incoming records with invalid length (impacted CBC encryption with 3DES or with the aes_small or aes_big AES implementations; only 3DES was selectable by default). Bug was reported by Thai Duong at Calif.io (with some AI stuff from Anthropic Research). --- diff --git a/src/ssl/ssl_rec_cbc.c b/src/ssl/ssl_rec_cbc.c index c38cbfd..9e89bb6 100644 --- a/src/ssl/ssl_rec_cbc.c +++ b/src/ssl/ssl_rec_cbc.c @@ -70,7 +70,7 @@ cbc_check_length(const br_sslrec_in_cbc_context *cc, size_t rlen) min_len += blen; max_len += blen; } - return min_len <= rlen && rlen <= max_len; + return min_len <= rlen && rlen <= max_len && (rlen & (blen - 1)) == 0; } /*