Skip to content

Commit e042182

Browse files
anhuJacobBarthelmeh
authored andcommitted
Fix TLS 1.3 PQC key share over heap read (ZD 21413)
Validate that the received key share data length (keLen) is at least as large as the expected ciphertext size (ctSz) before passing it to wc_KyberKey_Decapsulate. A malicious TLS 1.3 server could send a short ML-KEM key share.
1 parent 7aac9e5 commit e042182

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/tls.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9950,6 +9950,10 @@ static int TLSX_KeyShare_ProcessPqcClient_ex(WOLFSSL* ssl,
99509950
}
99519951
#endif
99529952

9953+
if (ret == 0 && keyShareEntry->keLen < ctSz) {
9954+
WOLFSSL_MSG("PQC key share data too short for ciphertext.");
9955+
ret = BUFFER_E;
9956+
}
99539957
if (ret == 0) {
99549958
ret = wc_KyberKey_Decapsulate(kem, ssOutput,
99559959
keyShareEntry->ke, ctSz);

0 commit comments

Comments
 (0)