The owner could possibliy withdraw his/her NFT before the winner claims it #181
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-146
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L90-L92
https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L173
https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L203
Vulnerability details
Impact
The admin/owner can claim the NFT as a last resort by calling
lastResortTimelockOwnerClaimNFT()
after recoverTimelock passes which is at least one week.https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L90-L92
However, the owner can create one (or even multiple) VRFNFTRandomDraw, wait till the recoverTimelock passes (e.g. one week) before start using the raffles.
This way, the owner can withdraw the NFT during the raffle at any time since the only check we have in
lastResortTimelockOwnerClaimNFT()
is:https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L306-L309
Let's have a look at the following scenario:
startDraw
function.lastResortTimelockOwnerClaimNFT()
to withdraw the NFT.redraw
to start the raffle again.As you can see this makes the raffle unfair as opposed to what the docs says:
Proof of Concept
forge test --match-path test/VRFNFTRandomDrawByPassTimeLock.t.sol -vv
It should be executed successfully.
Tools Used
Manual analysis
Recommended Mitigation Steps
Consider checking recoverTimelock upon
startDraw
andredraw
. if the recoverTimelock is not greater than currentTime+drawBufferTime then disallow using the raffle. A new raffle (VRFNFTRandomDraw contract) has to be created if this is already expired (or you can add a function to renew the recoverTimelock to keep using the same contract).The text was updated successfully, but these errors were encountered: