The top tier prover can not re-prove
The top-tier prover cannot re-prove a different transition because an assert incorrectly checks that contestBond is zero, while the default value is one. This causes the transaction to revert, preventing the intended re-proving.
Submitted by Shield, also found by zzebra83 and Tendency
In the LibProving.proveBlock function the top tier prover is allowed to prove a new transition as long as the new transition is different from the previous transition and assert conditional checks pass.
if (sameTransition) revert L1_ALREADY_PROVED();
if (isTopTier) {
// The top tier prover re-proves.
assert(tier.validityBond == 0);
assert(ts.validityBond == 0 && ts.contestBond == 0 && ts.contester == address(0));
But the assert condition of this logic is wrong since it checks for the ts.contestBond == 0 where as it should be ts.contestBond == 1 since 1 is set as the default value for ts.contestBond parameter for gas savings as shown below:
ts_.contestBond = 1; // to save gas
As a result of the even though code expects the top-tier prover to re-prove a different transition, the transaction will revert.
Proof of Concept
Add the following testcase test_L1_GuardianProverCanOverwriteIfNotSameProof_test to the TaikoL1LibProvingWithTiers.t.sol test file.
If you change the ts.contestBond == 0 to ts.contestBond == 1 in the second assert statement of the LibProving.proveBlock function, the test will run successfully and transaction execution will succeed.
function test_L1_GuardianProverCanOverwriteIfNotSameProof_test() external {
giveEthAndTko(Alice, 1e7 ether, 1000 ether);
giveEthAndTko(Carol, 1e7 ether, 1000 ether);
console2.log("Alice balance:", tko.balanceOf(Alice));
// This is a very weird test (code?) issue here.
// If this line is uncommented,
// Alice/Bob has no balance.. (Causing reverts !!!)
// Current investigations are ongoing with foundry team
giveEthAndTko(Bob, 1e7 ether, 100 ether);
console2.log("Bob balance:", tko.balanceOf(Bob));
// Bob
vm.prank(Bob, Bob);
bytes32 parentHash = GENESIS_BLOCK_HASH;
for (uint256 blockId = 1; blockId < conf.blockMaxProposals * 3; blockId++) {
printVariables("before propose");
(TaikoData.BlockMetadata memory meta,) = proposeBlock(Alice, Bob, 1_000_000, 1024);
//printVariables("after propose");
mine(1);
bytes32 blockHash = bytes32(1e10 + blockId);
bytes32 stateRoot = bytes32(1e9 + blockId);
// This proof cannot be verified obviously because of
// blockhash:blockId
proveBlock(Bob, Bob, meta, parentHash, stateRoot, stateRoot, LibTiers.TIER_GUARDIAN, "");
// Prove as guardian
proveBlock(
Carol, Carol, meta, parentHash, blockHash, stateRoot, LibTiers.TIER_GUARDIAN, ""
);
vm.roll(block.number + 15 * 12);
uint16 minTier = meta.minTier;
vm.warp(block.timestamp + tierProvider().getTier(LibTiers.TIER_GUARDIAN).cooldownWindow * 60 + 1);
verifyBlock(Carol, 1);
parentHash = blockHash;
}
printVariables("");
}
Tools Used
VSCode
Recommended Mitigation Steps
Hence recommended to update the ts.contestBond == 0 in the second assert statement to ts.contestBond == 1 in the LibProving.proveBlock function.
dantaik (Taiko) confirmed and commented:
This is a valid bug report, it has been fixed already here: https://github.com/taikoxyz/taiko-mono/pull/16543
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 assert condition checks ts.contestBond == 0 but the default value is 1, so the condition always fails.
Impact
The top-tier prover cannot re-prove a different transition, so the transaction reverts and the intended overwrite fails.
What the attacker needed
Top-tier prover role; a different transition to prove
The fix
The assert condition should be changed to check ts.contestBond == 1 instead of 0; the report says this was fixed.
How it was found
- Set up the test environment with Alice, Bob, and Carol having balances.
- Propose a block and mine it.
- Prove the block as Bob with the guardian tier.
- Prove the block as Carol with the guardian tier, attempting to overwrite the proof.
- Advance time and verify the block as Carol.
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 this smart contract, a special 'top-tier' prover is supposed to be able to replace a previous proof with a new one. But a check in the code expects a certain value to be zero when it is actually set to one by default, so the replacement always fails. This means the top-tier prover cannot do its job.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.