From cdcc3b323d85e53daea9ca66e74fb5192d32d992 Mon Sep 17 00:00:00 2001 From: nethoxa <135072738+nethoxa@users.noreply.github.com> Date: Wed, 28 May 2025 11:33:34 +0200 Subject: [PATCH] core: add overflow checks to IntrinsicGas --- core/state_transition.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/state_transition.go b/core/state_transition.go index 4f172682d0..0f218a242e 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -107,10 +107,20 @@ func IntrinsicGas(data []byte, accessList types.AccessList, authList []types.Set } } if accessList != nil { + if (math.MaxUint64-gas)/params.TxAccessListAddressGas < uint64(len(accessList)) { + return 0, ErrGasUintOverflow + } gas += uint64(len(accessList)) * params.TxAccessListAddressGas + + if (math.MaxUint64-gas)/params.TxAccessListStorageKeyGas < uint64(accessList.StorageKeys()) { + return 0, ErrGasUintOverflow + } gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas } if authList != nil { + if (math.MaxUint64-gas)/params.CallNewAccountGas < uint64(len(authList)) { + return 0, ErrGasUintOverflow + } gas += uint64(len(authList)) * params.CallNewAccountGas } return gas, nil