accounts/scwallet: fix panic in decryptAPDU (#33606)

Validate ciphertext length in decryptAPDU, preventing runtime panics on
invalid input.
This commit is contained in:
DeFi Junkie 2026-01-20 14:04:23 +03:00 committed by GitHub
parent d58f6291a2
commit 46d804776b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -300,6 +300,10 @@ func (s *SecureChannelSession) decryptAPDU(data []byte) ([]byte, error) {
return nil, err return nil, err
} }
if len(data) == 0 || len(data)%aes.BlockSize != 0 {
return nil, fmt.Errorf("invalid ciphertext length: %d", len(data))
}
ret := make([]byte, len(data)) ret := make([]byte, len(data))
crypter := cipher.NewCBCDecrypter(a, s.iv) crypter := cipher.NewCBCDecrypter(a, s.iv)