impose size limit for DecodeBytesExtraFields (#1637)

This commit is contained in:
Wanwiset Peerapatanapokin 2025-10-16 12:16:14 +04:00 committed by GitHub
parent 53f6a8d6d9
commit e0c987f45a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,6 +81,11 @@ func DecodeBytesExtraFields(b []byte, val interface{}) error {
if len(b) == 0 {
return errors.New("extra field is 0 length")
}
// Prevent payload attack, limit the size of extra field to 20k bytes. Normal Extrafield payload is less than 7k bytes.
if len(b) > 20000 {
return errors.New("extra field is too long")
}
switch b[0] {
case 2:
return rlp.DecodeBytes(b[1:], val)