Skip to content

Commit 10325b4

Browse files
committed
Fix integer underflow in ECH innerClientHelloLen parsing
Add bounds check before subtracting WC_AES_BLOCK_SIZE from the attacker-controlled innerClientHelloLen field in TLSX_ECH_Parse(). Values 0-15 caused a word16 underflow to ~65K, leading to a heap buffer overflow write via XMEMSET and heap buffer over-read via wc_AesGcmDecrypt. Return BAD_FUNC_ARG if the field is too small.
1 parent af329b3 commit 10325b4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/tls.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13605,6 +13605,9 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size,
1360513605
}
1360613606
/* read hello inner len */
1360713607
ato16(readBuf_p, &ech->innerClientHelloLen);
13608+
if (ech->innerClientHelloLen < WC_AES_BLOCK_SIZE) {
13609+
return BAD_FUNC_ARG;
13610+
}
1360813611
ech->innerClientHelloLen -= WC_AES_BLOCK_SIZE;
1360913612
readBuf_p += 2;
1361013613
ech->outerClientPayload = readBuf_p;

0 commit comments

Comments
 (0)