At the end of an epoch, the triggerEndEpoch(…) is called to trigger ‘epoch end without depeg event’, making risk users the winners and entitling them to withdraw (risk + hedge) from the vault. In the case of the Arbitrum sequencer going down or restarting, there is a grace period of one hour before the getLatestPrice() returns to execute without reverting. This means that the triggerEndEpoch(…) cannot complete during this time, because it calls the getLatestPrice().
Making this high-priority because unless the triggerEndEpoch(…) completes:
winners cannot withdraw althought the epoch is over;
during this time the strike price might be reached causing a depeg event at all effects turning the table for the winners;
Can execute if block.timestamp > epochEnd, but fails if trigger did not execute. Winners cannot withdraw.
function withdraw(
uint256 id,
uint256 assets,
address receiver,
address owner
)
external
override
epochHasEnded(id) // @audit same as require((block.timestamp > id) || idDepegged[id]), hence independent from triggers.
marketExists(id)
returns (uint256 shares)
{
< ... omitted ... >
uint256 entitledShares = beforeWithdraw(id, shares); // @audit ratio is idClaimTVL[id]/ifFinalTVL[id], hence zero unless triggers executed
< ... omitted ... >
emit Withdraw(msg.sender, receiver, owner, id, assets, entitledShares);
asset.transfer(receiver, entitledShares);
return entitledShares;
}
Recommended Mitigation Steps
The latest price is retrieved at the very end of the triggerEndEpoch(…) for the only purpose of initializing the DepegInsurance event. Since it is used for informational purpose (logging / offchain logging) and not for functional purpose to the triggerEndEpoch(…) execution, it can be relaxed.
Depending on how the event is used, when getLatestPrice() is called for informative/logging purpose only, there could be few alternatives:
log a 0 when SequencerDown or GRACEPERIODTIME not passed
log a 0 when SequencerDown and ignore GRACEPERIODTIME
Once events are logged off-chain, some post processing may be used to correct/update the values with accurate data.
Agree with the points raised by the warden, especially on how getLatestPrice() is merely for informational purposes in the event emission.
The original report as published on Code4rena, by eierina. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is known
A high-severity doS bug in Y2k Finance contest. Code4rena made it public on 9 January 2023. Found in the 2022-09-y2k-finance audit contest (finding H-02).
About DoS
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.