In some cases, proper CLOCK_EXTENTSION time cannot be ensured to generate the initial instruction trace
The clock extension logic in the FaultDisputeGame contract fails to grant the full doubled extension period when a team needs to generate an execution trace bisection root claim and counter a claim. This can leave a team with only half the intended time, potentially causing their clock to run out prematurely.
oakcobalt Follow with xuwinnie, RadiantLabs and 2 others
Originally disclosed on Code4rena
Submitted by oakcobalt, also found by xuwinnie, RadiantLabs, Zubat, and ether_sky
In some cases, a team will not be granted enough CLOCK_EXTENSION time to generate the initial instruction trace and perform a counter claim.
Proof of Concept
In FaultDisputeGame::move, game clocks will grant extensions to ensure a team has enough time to counter a potential claim and/or generate an execution trace bisection root claim. A special case is when the potential grandchild is executiontrace bisection root claim (SPLIT_DEPTH + 1), twice the extension time (2 * CLOCK_EXTENSION.raw()) should be ensured.
The problem is that the current implementation might still cause a team to have less than 2 * CLOCK_EXTENSION.raw() time to generate an execution trace bisection root claim and perform a counterclaim. Specifically, if (nextDuration.raw() > MAX_CLOCK_DURATION.raw() - CLOCK_EXTENSION.raw()) condition check is vulnerable.
//packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
function move(
Claim _disputed,
uint256 _challengeIndex,
Claim _claim,
bool _isAttack
) public payable virtual {
...
|> if (nextDuration.raw() > MAX_CLOCK_DURATION.raw() - CLOCK_EXTENSION.raw()) {
// If the potential grandchild is an execution trace bisection root, double the clock extension.
uint64 extensionPeriod =
nextPositionDepth == SPLIT_DEPTH - 1 ? CLOCK_EXTENSION.raw() * 2 : CLOCK_EXTENSION.raw();
nextDuration = Duration.wrap(MAX_CLOCK_DURATION.raw() - extensionPeriod);
}
...
Suppose CLOCK_EXTENSION.raw() is 3 hours, MAX_CLOCK_DURATION.raw() is 84 hours (3.5 days).
Case A: At time of move(), nextDuration.raw() is 82 hours. nextPosition is at SPLIT_DEPTH -1
nextDuration.raw() > MAX_CLOCK_DURATION.raw() - CLOCK_EXTENSION.raw(). The grandchild is at SPLIT_DEPTH + 1 (execution trace root).
extensionPeriod: 6h (CLOCK_EXTENSION.raw() * 2) nextDuration: 78h (MAX_CLOCK_DURATION.raw() - CLOCK_EXTENSION.raw() * 2)
Case B: At time of move(), nextDuration.raw() is 81 hours. nextPosition is at SPLIT_DEPTH -1.
B-1: nextDuration.raw() == MAX_CLOCK_DURATION.raw() - CLOCK_EXTENSION.raw(). The grandchild is at SPLIT_DEPTH + 1 (execution trace root).
The if condition will be bypassed.
extensionPeriod: 0h nextDuration: 81h
B-2: The opposing team attack.
B-3: The grandchild now has max. 3h to generate execution trace root claim and perform a counter claim. This is half of the intended CLOCK_EXTENSION.raw() * 2.
As seen in Case B, in normal conditions, a team that need to create both executiontrace root claim and perform a counter claim may not get the minimum CLOCK_EXTENSION.raw() * 2 time. A team’s clock may run out prematurely.
Recommended Mitigation Steps
Consider change to the following:
...
uint64 extensionPeriod;
if (nextPositionDepth != SPLIT_DEPTH - 1 && (nextDuration.raw() > MAX_CLOCK_DURATION.raw() - CLOCK_EXTENSION.raw())) {
extensionPeriod = CLOCK_EXTENSION.raw();
} else if (nextPositionDepth == SPLIT_DEPTH - 1 && (nextDuration.raw() > MAX_CLOCK_DURATION.raw() - 2* CLOCK_EXTENSION.raw())) {
extensionPeriod = CLOCK_EXTENSION.raw() * 2;
}
nextDuration = Duration.wrap(MAX_CLOCK_DURATION.raw() - extensionPeriod);
...
ajsutton (Optimism) confirmed and commented:
This is accurate. There was a fair bit of debate about whether
2 * CLOCK_EXTENSIONwas actually required at the split depth so this doesn’t concern me, though if we extend the limit for one side it seems reasonable to expect it to be extended for the other side as well.
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 condition for applying the clock extension uses a single threshold that does not account for the doubled extension needed at the split depth, so when the remaining time equals the maximum minus one extension, the extension is skipped entirely.
Impact
A team may have only half the intended time to generate an execution trace root claim and counter a claim, so their clock could run out prematurely.
What the attacker needed
NextDuration.raw() equals MAX_CLOCK_DURATION.raw() -…; nextPosition is at SPLIT_DEPTH - 1; opposing team attacks
The fix
The condition should be split so that the doubled extension is applied when the next position is at the split depth and the remaining time exceeds the maximum minus twice the extension.
How it was found
- At the time of move(), nextDuration.raw() is 81 hours and nextPosition is at SPLIT_DEPTH -1.
- The grandchild is at SPLIT_DEPTH + 1 (execution trace root).
- The if condition is bypassed, so extensionPeriod is 0h and nextDuration remains 81h.
- The opposing team attacks.
- The grandchild now has at most 3 hours to generate the execution trace root claim and perform a counter claim.
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 a dispute game, teams have limited time to respond to claims. The code is supposed to give extra time when a team must produce a complex claim, but a boundary condition means the extra time is sometimes not given, so a team could run out of time unfairly.
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.