From 7bc78fb892e5e4b324204cc493876ec5109d0b9b Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Fri, 20 Dec 2024 16:41:27 +0900 Subject: [PATCH] don't allow tail garbage in client hello --- tls/Network/TLS/Packet.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tls/Network/TLS/Packet.hs b/tls/Network/TLS/Packet.hs index 096974584..7e79501e3 100644 --- a/tls/Network/TLS/Packet.hs +++ b/tls/Network/TLS/Packet.hs @@ -172,10 +172,9 @@ decodeClientHello = do exts <- if r > 0 then fromIntegral <$> getWord16 >>= getExtensions - else do - rest <- remaining - _ <- getBytes rest - return [] + else return [] + r1 <- remaining + when (r1 /= 0) $ fail "Client hello" let ch = CH session ciphers exts return $ ClientHello ver random compressions ch