Admin does not have to wait to call lastResortTimelockOwnerClaimNFT()
The recoverTimelock is set only during initialization and never updated for each draw, so the admin can call lastResortTimelockOwnerClaimNFT() before the intended waiting period after a winner is chosen. This lets the admin cancel the raffle and claim the NFT earlier than the specification allows.
Submitted by Soosh, also found by dipp, indijanc, maks, jadezti, gz627, sces60107, Zarf, neumo, Ch_301, imare, Trust, btk, kuldeep, bin2chen, immeas, obront, hansfriese, Koolex, Apocalypto, carrotsmuggler, hihen, HE1M, rvierdiiev, SmartSek, 9svR6w, sk8erboy, ladboy233, Titi, dic0de, and csanuragjain
On contest page: "If no users ultimately claim the NFT, the admin specifies a timelock period after which they can retrieve the raffled NFT."
Let’s assume a recoverTimelock of 1 week.
The specification suggests that 1 week from the winner not having claimed the NFT. Meaning that the admin should only be able to call lastResortTimelockOwnerClaimNFT() only after <block.timestamp at fulfillRandomWords()> + request.drawTimelock + 1 weeks.
Specification:
drawTimelock recoverTimelock
│ │
▼ ▼
┌────┬──────────────────────────────┐
│ │ 1 week │
└────┴──────────────────────────────┘
▲
│
fulfillRandomWords()
- The winner should have up to
drawTimelockto claim before an admin can callredraw()and pick a new winner. - The winner should have up to
recoverTimelockto claim before an admin can calllastResortTimelockOwnerClaimNFT()to cancel the raffle.
But this is not the case.
recoverTimelock is set in the initialize(...) function and nowhere else. That means 1 week from initialization, the admin can call lastResortTimelockOwnerClaimNFT(). redraw() also does not update recoverTimelock.
In fact, startDraw() does not have to be called at the same time as initialize(...). That means that if the draw was started after having been initialized for 1 week, the admin can withdraw at any time after that.
Impact
Protocol does not work as intended.
Recommended Mitigation Steps
Just like for drawTimelock, recoverTimelock should also be updated for each dice roll. <block.timestamp at fulfillRandomWords()> + request.drawTimelock + <recoverBufferTime>. Where <recoverBufferTime> is essentially the drawBufferTime currently used, but for recoverTimelock.
Note: currently, drawTimelock is updated in the _requestRoll() function. This is “technically less correct” as chainlink will take some time before fulfillRandomWords(...) callback. So the timelock is actually set before the winner has been chosen. This should be insignificant under normal network conditions (Chainlink VRF shouldn’t take > 1min) but both timelocks should be updated in the same function - either _requestRoll() or fulfillRandomWords(...).
iainnash (Forgeries) confirmed and commented:
This seems to be a dupe of a previous issue where the timelock is not passed.
Give this timelock is validated from the end of the auction the risk here seems Low.
gzeon (judge) increased severity to High and commented:
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 recoverTimelock is only set during initialization and not updated when a new draw is requested or fulfilled, so the admin's claim window is measured from initialization rather than from the winner selection.
Impact
The admin could call lastResortTimelockOwnerClaimNFT() earlier than intended, potentially claiming the NFT before the winner has had the full recoverTimelock period to claim it.
What the attacker needed
Admin role; raffle initialized
The fix
The recoverTimelock should be updated for each draw, for example to the timestamp at fulfillRandomWords() plus drawTimelock plus a recover buffer time, similar to how drawTimelock is handled.
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 raffle, the winner should have a set time to claim their prize before the admin can take it back. Here, the timer for the admin's backup claim starts when the raffle is set up, not when a winner is picked, so the admin can take the prize too soon.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.