From c19c8418b3421f1995b7b7894f65e2259649ac24 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Fri, 13 May 2022 11:21:39 +0800 Subject: [PATCH] fix: add length check for ssr auth_aes128_sha1 (#2129) --- transport/ssr/protocol/auth_aes128_sha1.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transport/ssr/protocol/auth_aes128_sha1.go b/transport/ssr/protocol/auth_aes128_sha1.go index d31fb9bf..7b4da962 100644 --- a/transport/ssr/protocol/auth_aes128_sha1.go +++ b/transport/ssr/protocol/auth_aes128_sha1.go @@ -154,6 +154,9 @@ func (a *authAES128) Encode(buf *bytes.Buffer, b []byte) error { } func (a *authAES128) DecodePacket(b []byte) ([]byte, error) { + if len(b) < 4 { + return nil, errAuthAES128LengthError + } if !bytes.Equal(a.hmac(a.Key, b[:len(b)-4])[:4], b[len(b)-4:]) { return nil, errAuthAES128ChksumError }