Taiko L1 - Proposer can maliciously cause loss of funds by forcing someone else to pay prover’s fee
The block proposer could set the coinbase field to any address, and the assignment hook used that field as the payer of the prover fee in ERC20 tokens. An attacker could therefore name another user as coinbase and make that user pay the prover fee for the attacker's block.
zzebra83 Follow with MrPotatoMagic, monrel and 2 others
Originally disclosed on Code4rena
Submitted by zzebra83, also found by MrPotatoMagic, monrel, mojito_auditor, and ladboy233
Proposal of new blocks triggers a call to proposeBlock in the libProposing library. In that function, there is this the following block of code:
if (params.coinbase == address(0)) {
params.coinbase = msg.sender;
}
This sets the params.coinbase variable set by the caller of the function to be the msg.sender if it was empty.
As part of the process of proposal, hooks can be called of type AssignmentHook. An assignment hook’s onBlockProposed will be triggered as follows:
// When a hook is called, all ether in this contract will be send to the hook.
// If the ether sent to the hook is not used entirely, the hook shall send the Ether
// back to this contract for the next hook to use.
// Proposers shall choose use extra hooks wisely.
IHook(params.hookCalls[i].hook).onBlockProposed{ value: address(this).balance }(
blk, meta_, params.hookCalls[i].data
);
Notice how the meta data is passed to this function. Part of the function of the onBlockProposed is to pay the assigned prover their fee and the payee should be the current proposer of the block. this is done as follows:
// The proposer irrevocably pays a fee to the assigned prover, either in
// Ether or ERC20 tokens.
if (assignment.feeToken == address(0)) {
// Paying Ether
_blk.assignedProver.sendEther(proverFee, MAX_GAS_PAYING_PROVER);
} else {
// Paying ERC20 tokens
IERC20(assignment.feeToken).safeTransferFrom(
_meta.coinbase, _blk.assignedProver, proverFee
);
}
Notice how if the payment is in ERC20 tokens, the payee will be the variable _meta.coinbase, and like we showed earlier, this can be set to any arbitrary address by the proposer. This can lead to a scenario as such:
- proposer A approves the assignmentHook contract to spend a portion of their tokens, the allowance is set higher than the actual fee they will be paying.
- proposer A proposes a block, and a fee is charged and payed to the assigned prover, but there remains allowance that the assignment hook contract can still use.
- proposer B proposes a block and sets params.coinbase as the the address of proposer A.
- proposer A address will be the payee of the fee for the assigned prover for the block proposed by proposer B.
The scenario above describes how someone can be forced maliciously to pay fees for block proposals by other actors.
Recommended Mitigation Steps
A simple fix to this to ensure the block proposer will always be the msg.sender, as such:
if (params.coinbase == address(0 || params.coinbase != msg.sender)) {
params.coinbase = msg.sender;
}
dantaik (Taiko) confirmed and commented:
This is a valid bug report. It has been fixed here: https://github.com/taikoxyz/taiko-mono/pull/16327
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 coinbase field was only defaulted to the sender when empty, so a caller could supply any address and have the ERC20 prover fee pulled from it.
Impact
A user who has left a token allowance to the hook could be forced to pay prover fees for blocks proposed by someone else, losing funds.
What the attacker needed
Victim has approved the hook contract; attacker can propose a block; ERC20 fee token in use
The fix
The coinbase should always be forced to the sender, and the project confirmed it was fixed.
How it was found
- Proposer A approves the assignment hook contract to spend more tokens than the fee they will pay.
- Proposer A proposes a block and pays the prover fee, leaving allowance remaining.
- Proposer B proposes a block and sets the coinbase to proposer A's address.
- Proposer A's address pays the prover fee for proposer B's block.
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 a block is proposed, a fee is paid to the prover who will later prove it. If the fee is in tokens, the contract takes the money from an address stored in the block's coinbase field. The proposer controls that field, so they could put someone else's address there and that person's tokens would be taken to pay the fee.
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.