Skip to content
DoS Audit finding Advanced

Minievm fails to charge intrinsic gas costs for EVM transactions, allowing the abuse of the accesslist to consume computational resources without proper compensation

The minievm module did not charge intrinsic gas for EVM transactions, so access list entries were processed without the corresponding gas cost. An attacker could supply many distinct addresses in the access list to consume computational resources without paying for them, creating a denial-of-service risk.

berndartmueller Follow

Originally disclosed on Code4rena

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

Finding description and impact

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.

Proof of Concept

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 transaction’s 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 SLOAD‘s.

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.

Recommended mitigation steps

Consider charging intrinsic transaction gas, that considers the accesslist, as per EIP-2930.

leojin (Initia) confirmed and commented:

We fixed the intrinsic gas charge in this PR. But, since gas is charged on the cosmos side based on the transaction’s data size (like intrinsic gas do), it does not pose a significant DoS risk; therefore, its security level can be considered lower.

berndartmueller (warden) commented:

It’s correct that the ConsumeTxSizeGasDecorator ante decorator charges gas per tx byte:

ctx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*storetypes.Gas(len(ctx.TxBytes())), "txSize")

where TxSizeCostPerByte = 10 by default.

However, this is, in my opinion, not sufficient. Considering that the access list AccessList []AccessTuple is basically an array of EVM addresses (Address string), which needs 20 bytes + a few bytes of overhead for the encoding per entry. To simplify calculations, let’s assume that an address entry in the access list requires 30 bytes. This results in 30 * 10 = 300 gas being charged by ConsumeTxSizeGasDecorator(..).

However, this single access list entry equals 2600 of gas that would have been charged if the access list is considered in the intrinsic gas. That’s a 2600 - 300 = 2300 gap.

Hence, the gas that is charged per tx byte is not sufficient, leaving the DoS risk to be significant and justifying high severity.

LSDan (judge) commented:

Thank you for the clarified example. On review, I agree that this rises to the level of high risk.

Initia mitigated:

Fixed intrinsic gas charge.

Status: Mitigation confirmed. Full details in reports from 0xAlix2, berndartmueller and Franfran.


The original report as published on Code4rena, by berndartmueller. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the EVM call and create functions did not add the intrinsic gas cost, including the access list cost defined by EIP-2930, before executing the transaction.

Impact

An attacker could include many distinct contract addresses in the access list to consume computational resources without proper compensation, posing a significant denial-of-service risk; the Cosmos-side per-byte gas charge was argued to be insufficient to offset this.

What the attacker needed

Ability to submit EVM transactions; craft an access list with many addresses

The fix

The project fixed the intrinsic gas charge in a pull request, and the mitigation was confirmed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Gas is a fee paid for the computing work a transaction uses. Some work, like reading a list of addresses attached to a transaction, should cost extra gas. Here that extra fee was skipped, so someone could make the system do a lot of work for free and slow it down for others.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by berndartmueller

View all

97 more disclosed reports, best first.

More from Initia Cosmos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.