Block policy discounts gas price by incorrectly applying EIP-1559 to legacy transactions
The block policy incorrectly applies the EIP-1559 base fee ceiling to legacy transactions, underestimating their maximum gas cost. This allows transactions to be included in a block even when the sender's balance cannot cover the gas fees, potentially causing the block to be invalidated and enabling spam without paying fees.
RadiantLabs Follow with 0x15 and 0xAsen
Originally disclosed on Code4rena
Submitted by RadiantLabs, also found by 0x15 and 0xAsen
bft/monad-eth-block-policy/src/lib.rs #L77
Block policy implements static tracking of account balances and nonce updates to allow consensus to lead execution by k blocks, by allowing only valid transactions to be included in a block.
How it does it is by tracking the “worst case balance” and “nonce” of each account sending transactions and signing EIP-7702 authorizations.
In the case of the “worst case balance” calculation, there is a miscalculation in the compute_txn_max_gas_cost function, where the base_fee ceiling is applied to transactions that are not EIP-1559 (aka legacy transactions):
File: bft/monad-eth-block-policy/src/lib.rs
77: pub fn compute_txn_max_gas_cost(txn: &TxEnvelope, base_fee: u64) -> U256 {
78: let gas_limit = U256::from(txn.gas_limit());
79: let max_fee = U256::from(txn.max_fee_per_gas());
80: let priority_fee = U256::from(txn.max_priority_fee_per_gas().unwrap_or(0));
81: let base_fee = U256::from(base_fee);
82: let gas_bid = max_fee.min(base_fee.saturating_add(priority_fee));
83: gas_limit.checked_mul(gas_bid).expect("no overflow")
84: }
This contrasts with the execution layer which instead excludes legacy transactions from the EIP-1559 gas ceiling:
File: bft/monad-cxx/monad-execution/category/execution/ethereum/transaction_gas.cpp
144: inline constexpr uint256_t priority_fee_per_gas(
145: Transaction const &tx, uint256_t const &base_fee_per_gas) noexcept
146: {
147: MONAD_ASSERT(tx.max_fee_per_gas >= base_fee_per_gas);
148: auto const max_priority_fee_per_gas = tx.max_fee_per_gas - base_fee_per_gas;
149:
150: if (tx.type == TransactionType::eip1559 ||
151: tx.type == TransactionType::eip4844 ||
152: tx.type == TransactionType::eip7702) {
153: return std::min(tx.max_priority_fee_per_gas, max_priority_fee_per_gas);
154: }
155: // EIP-1559: "Legacy Ethereum transactions will still work and
156: // be included in blocks, but they will not benefit directly from
157: // the new pricing system. This is due to the fact that upgrading
158: // from legacy transactions to new transactions results in the
159: // legacy transaction’s gas_price entirely being consumed either
160: // by the base_fee_per_gas and the priority_fee_per_gas."
161: return max_priority_fee_per_gas;
162: }
As a result of the bug in the consensus logic, the gas cost of a transaction can be underestimated, allowing transactions to be included in a block when the sender’s balance is not sufficient to guarantee cover for the gas fees.
When these transactions reach execution, the C++ logic will mark them invalid, eventually invalidating the whole block (because transactions that revert are acceptable in a valid block but invalid transactions aren’t).
Apart from the DoS scenario of invalid transactions poisoning blocks, this vulnerability also opens up a scenario where malicious actors can have consensus and include an arbitrarily high number of transactions without paying any fees, thus circumventing the economic barrier of gas that protects the Monad nodes’ infrastructure from abuse.
Recommended mitigation steps
Fix block policy to calculate legacy transaction gas cost as gas_limit * gas_price like done in execution.
View detailed Proof of Concept
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
The block policy's gas cost calculation applies the EIP-1559 base fee ceiling to legacy transactions, unlike the execution layer which excludes them.
Impact
This could allow invalid transactions to poison blocks, causing them to be rejected, and let attackers include many transactions without paying fees, bypassing the economic barrier that protects node infrastructure.
What the attacker needed
None
The fix
The block policy should calculate legacy transaction gas cost as gas_limit multiplied by gas_price, matching the execution layer.
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.
In Ethereum-style blockchains, before a transaction is added to a block, the system checks that the sender has enough money to pay for the maximum possible gas fee. This report found that for older-style transactions (called legacy), the check used a wrong formula, so it thought the fee would be lower than it actually is. That means a transaction could be accepted into a block even though the sender cannot actually pay, which later makes the whole block invalid.
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.