Submitted by berndartmueller
https://github.com/initia-labs/minievm/blob/744563dc6a642f054b4543db008df22664e4c125/x/evm/keeper/context.go#L372-L385
https://github.com/initia-labs/minievm/blob/744563dc6a642f054b4543db008df22664e4c125/x/evm/keeper/context.go#L243-L252
https://github.com/initia-labs/minievm/blob/744563dc6a642f054b4543db008df22664e4c125/x/evm/keeper/context.go#L277-L290
The minievm fails to charge intrinsic gas costs for EVM transactions in EVMStaticCallWithTracer(), EVMCallWithTracer(), and EVMCreateWithTracer(). In the EVM, intrinsic gas costs are considered costs for e.g., the accesslist (EIP-2930). For comparison, Evmos charges the intrinsic gas here.
According to the comment in x/evm/state/statedb.go#L610, EIP-2930 (access lists) is supposed to be supported. Overall, this represents a significant DoS risk to the network, as it allows for the potential abuse of computational resources without proper compensation.
Per EIP-2930, the Berlin hard fork raised the cold cost of account access opcodes (such as BALANCE, all CALL(s), and EXT*) to 2600 and raised the cold cost of state access opcode (SLOAD) from 800 to 2100 while lowering the warm cost for both to 100.
However, EIP-2930 has the added benefit of lowering transaction costs due to the transactions 200 gas discount.
As a result, instead of paying 2600 and 2100 gas for a CALL and SLOAD respectively, the transaction only requires 2400 and 1900 gas for cold access, and subsequent warm access will only cost 100 gas.
In the EVM, makeCallVariantGasCallEIP2929 checks if the address is warm. If so, the gas costs are reduced. This is under the premise that the intrinsic gas costs have been paid upfront, which include the accesslist costs.
However, as the intrinsic gas is not charged at all in minievm, neither the regular 2600 and 2100 nor the discounted 2400 and 1900 gas for the CALL and SLOAD opcodes is paid for.
By providing a large number of distinct contract addresses in the accesslist, the user does not properly pay for the computational resources required to load the code from storage. Similar with SLOADs.
This is additionally magnified by the fact that the access list is iterated on-chain when processing the message, utilizing uncapped computational resources which the user does not explicitly pay for.
Consider charging intrinsic transaction gas, that considers the accesslist, as per EIP-2930.
leojin (Initia) confirmed and commented:
berndartmueller (warden) commented:
LSDan (judge) commented:
Initia mitigated:
Status: Mitigation confirmed. Full details in reports from 0xAlix2, berndartmueller and Franfran.
