There is no slippage check for the eth deposits processing in the LibDepositing.processDeposits
The deposit processing function charges a fee based on the current L1 block basefee without any slippage check, so if the basefee rises significantly before the deposit is processed, the recipient can lose a large portion of the deposited amount. An attacker cannot directly trigger this, but users are exposed to unpredictable fee deductions.
Submitted by Shield, also found by ladboy233
The LibDepositing.depositEtherToL2 function is called by the TaikoL1.depositEtherToL2 to deposit ether to the L2 chain. The maximum number of unprocessed eth deposits are capped at _config.ethDepositRingBufferSize - 1 as shown here:
unchecked {
return _amount >= _config.ethDepositMinAmount && _amount <= _config.ethDepositMaxAmount
&& _state.slotA.numEthDeposits - _state.slotA.nextEthDepositToProcess
< _config.ethDepositRingBufferSize - 1;
}
The Taiko configuration states that ethDepositRingBufferSize == 1024. Hence the maximum unprocessed eth deposits allowed by the taiko L1 contract is capped at 1023.
When the L2 block is proposed by calling the LibProposing.proposeBlock function by the TaikoL1 contract, it processes the unprocessed eth deposits by calling the LibDepositing.processDeposits. But it is allowed to process at most 32 eth deposits per block as per the following conditional check in the processDeposits function.
deposits_ = new TaikoData.EthDeposit[(numPending.min(_config.ethDepositMaxCountPerBlock));
Here the ethDepositMaxCountPerBlock == 32 as configured in the TaikoL1.getConfig function.
And the fee amount for each of the eth deposits are calculated as follows:
uint96 fee = uint96(_config.ethDepositMaxFee.min(block.basefee * _config.ethDepositGas));
uint96 _fee = deposits_[i].amount > fee ? fee : deposits_[i].amount;
deposits_[i].amount -= _fee;
Hence the deposited eth amount is deducted by the calculated _fee amount for the eth deposit transaction. If the basefee of the L1 block increases significantly then the maximum fee of ethDepositMaxFee: 1 ether / 10 will be applied. Thus deducting that amount from the transferred eth deposit to the recipient in L2.
Now let’s consider the following scenario:
nextEthDepositToProcessis currently100.numEthDepositsis1060currently.- The number of proposed L2 blocks required to process 1060th eth deposit is = 1060 - 100 / 32 = 30 L2 blocks.
- As a result all the
above 30 L2 blockswill not be proposed in a single L1 block and will require multiple L1 blocks for it. - If there is
huge congestionin the mainnet during this time theblock.basefeeof the subsequentL1 blockswould increase. And this could prompt the maximum fee of_config.ethDepositMaxFeeto be charged on the deposited amount (in theLibDepositing.processDepositsfunction, since subsequent L1 block would have a higherblock.basefee) thus prompting loss of funds on the recipient. - For example let’s assume the depositor deposit
1.1 etherand current gas fee is0.01 ether. Hence the recipient expects to receive approximately1.09 etherat the time of the deposit on L1. But when the deposit is processed in a subsequent L1 block, if the fee amount increases to the maximum amount of0.1 etherthen the recipient will only get approximately1 etheronly. This will cost the recipient aloss of 0.9 ether. If there was a slippage check a depositor can set for his eth deposits then the he can prevent excessive gas costs during processing.
Proof of Concept
unchecked {
return _amount >= _config.ethDepositMinAmount && _amount <= _config.ethDepositMaxAmount
&& _state.slotA.numEthDeposits - _state.slotA.nextEthDepositToProcess
< _config.ethDepositRingBufferSize - 1;
}
ethDepositRingBufferSize: 1024,
ethDepositMinCountPerBlock: 8,
ethDepositMaxCountPerBlock: 32,
uint96 fee = uint96(_config.ethDepositMaxFee.min(block.basefee * _config.ethDepositGas));
uint96 _fee = deposits_[i].amount > fee ? fee : deposits_[i].amount;
deposits_[i].amount -= _fee;
Tools Used
VSCode
Recommended Mitigation Steps
Hence it is recommended to add a slippage check for the fee amount of the deposited eth amount in the LibDepositing.processDeposits function, since depositEtherToL2 and processDepositare two different transactions with a delay during which the L1 block basefee can increase significantly causing loss of funds to the recipient in the form of fee increase.
dantaik (Taiko) acknowledged, but disagreed with severity and commented:
Thank you for the feedback. The current issue is valid but minor as we believe users can choose not to deposit Ether using the
depositEtherToL2function if there are already many deposits pending in the queue. Going forward, the processing of such deposits will likely be moved to the node software directly.
Agree this is valid, the impact is most likely small, but I think the likelihood of it occurring at some point is relatively high. The user is exposed to non-deterministic behavior that they cannot fully understand ahead of signing a transaction.
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 deposit processing calculates the fee using the current block's basefee at processing time, without allowing the depositor to set a maximum acceptable fee.
Impact
The recipient could lose a significant portion of the deposited amount if the L1 basefee rises before processing, though the likelihood depends on network congestion and the team considers it minor.
What the attacker needed
User deposits ether via depositEtherToL2; L1 basefee rises before processing
The fix
A slippage check should be added so the depositor can specify a maximum acceptable fee for the deposit processing.
How it was found
- A user deposits ether via depositEtherToL2, expecting a certain fee based on the current basefee.
- The deposit is queued and processed later in a subsequent L1 block.
- If the basefee has risen significantly by then, the fee is recalculated and may hit the maximum.
- The recipient receives less ether than expected due to the higher fee.
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.
When you send ether to another chain through this contract, the fee is calculated later, when the deposit is actually processed. If the network is busy at that later time, the fee can jump to a maximum, and you receive less than you expected. There is no way to say 'don't process if the fee is too high'.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.