From c3f4e1ba2e2d7fffd4d8786d76f2ac1948f17733 Mon Sep 17 00:00:00 2001 From: Kaming Chan 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 }