Emergency resolver targets wrong epoch
The emergency resolution function reads the market's current epoch and passes it to the resolver, but in time-based markets that value has already rolled forward to the new trading period. An authorised matcher calling it after a rollover therefore resolves the wrong epoch, leaving the earlier epoch without a merkle root so users cannot claim winnings and locking the new epoch to an incorrect root.
Source: https://github.com/sherlock-audit/2025-10-index-fun-order-book-contest-judging/issues/47
Found by
0xeix, 0xnija, 8olidity, DemiGods, Edoscoba, Icarus, Idealz, KrisRenZo, RajeshKotaru, Sir_Shades, Ziusz, blockace, jo13, neeloy, ubl4nk, x15
emergencyResolveMarket grabs currentEpoch from the market and forwards it to the resolver .
// src/Market/MarketController.sol:745-758
function emergencyResolveMarket(bytes32 questionId, uint256 numberOfOutcomes, bytes32 merkleRoot)
external
onlyAuthorizedMatcher
{
require(market.isMarketReadyForResolution(questionId), "Market not ready for resolution");
// Validate numberOfOutcomes parameter matches the actual market
uint256 actualOutcomes = market.getOutcomeCount(questionId);
require(actualOutcomes > 0, "Market not found");
require(numberOfOutcomes == actualOutcomes, "Outcome count mismatch");
require(numberOfOutcomes <= 256, "Maximum 256 outcomes supported");
uint256 currentEpoch = market.getCurrentEpoch(questionId);
marketResolver.resolveMarketEpoch(questionId, currentEpoch, numberOfOutcomes, merkleRoot);
emit EmergencyResolution(questionId, currentEpoch, merkleRoot);
}
In time-based markets getCurrentEpoch returns 1 + elapsed/duration, so once the new window starts the current epoch already points at the active trading period.
// src/Market/Market.sol:222-236
function getCurrentEpoch(bytes32 questionId) public view returns (uint256) {
if (!marketExists[questionId]) {
return 0;
}
uint256 duration = epochDuration[questionId];
// Manual epoch mode (legacy behavior)
if (duration == 0) {
return currentEpoch[questionId];
}
// Time-based epoch mode (automatic rolling)
uint256 elapsed = block.timestamp - epochStartTime[questionId];
return 1 + (elapsed / duration);
}
Because daily/weekly markets configure resolutionTime = 0 (see controller comments), market.isMarketReadyForResolution is always true. An authorized matcher can legitimately call the emergency function hours after an epoch rolled. At that point currentEpoch has advanced, so the controller resolves the new epoch while the previous one remains unresolved.
The resolver then stores the merkle root under the wrong condition id and marks it resolved. Epoch 1’s condition id never gets a root, so users cannot claim winnings for that period, and epoch 2 is now locked to the incorrect root. There is no way for the matcher to repair this via the controller because the function lacks an epoch parameter.
Recommendation
Add an explicit epoch parameter to emergencyResolveMarket and require the caller to choose which epoch to resolve. Guard that value with require(epoch > 0 && epoch <= market.getCurrentEpoch(questionId)) and, for time-based markets, optionally ensure epoch < market.getCurrentEpoch(questionId) so only closed epochs can be resolved
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/index-fun/orderbook-solidity/pull/54
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 emergency function derives the epoch to resolve from the market's live current-epoch value instead of accepting an explicit epoch, so a rollover between the intended and actual call shifts the target.
Impact
Users cannot claim winnings for the skipped epoch and the following epoch is locked to an incorrect root, with no way to repair it through the controller; the text does not claim any loss of funds beyond that.
What the attacker needed
Caller is an authorised matcher; time-based market with rolling epochs; call made after an epoch rollover
The fix
The protocol team fixed this issue by adding an explicit epoch parameter to the emergency function and validating it against the market's current epoch.
How it was found
- An authorised matcher intends to resolve a finished epoch of a time-based market.
- The epoch window rolls over before the emergency call is made.
- The function reads the now-advanced current epoch and forwards it to the resolver.
- The resolver stores the merkle root under the new epoch's condition id and marks it resolved.
- The earlier epoch's condition id never receives a root, so claims for that period fail.
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.
Markets here run in repeating periods called epochs, and each period needs a published list (a merkle root) so winners can prove and claim their payouts. The emergency function was meant to publish that list for a finished period, but it looked up the period that is currently running instead of the one that just ended. So the finished period never got its list and payouts for it were stuck, while the running period got the wrong list.
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.