Owner can rug reward NFT from the winner #171
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-146
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
upgraded by judge
Original issue severity upgraded from QA/Gas by judge
Lines of code
https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L83-L88
https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L159
https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L314-L317
Vulnerability details
Impact
Settings variable
drawBufferTime
represents the buffer time that forbids owner to triggerredraw
and thus allows winner to claim the reward NFT viawinnerClaimNFT
function. There is also anotherrecoverTimelock
settings variable that defines time when the owner can reclaim the reward NFT vialastResortTimelockOwnerClaimNFT
. The issue is thatdrawBufferTime
andrecoverTimelock
are not correctly checked which leads to situation that both triggeringwinnerClaimNFT
andlastResortTimelockOwnerClaimNFT
is possible.Example 1:
drawBufferTime
1 monthrecoverTimeLock
1 weekstartDraw()
is called by the ownerdrawTimeLock
is set to the next monthrecoverTimeLock
is always set to 1 weekThe issue is also present in case there are multiple redraws (via
redraw
function) that lead to expiration ofrecoverTimeLock
which allows owner to triggerlastResortTimelockOwnerClaimNFT
function.Proof of Concept
Recommended Mitigation Steps
It is recommended to set
drawBufferTime
andrecoverTimeLock
to values that will hold relationshiprecoverTimeLock = block.timestamp + drawBufferTime + X
. In addition value ofrecoverTimeLock
should be set properly in every_requestRoll
function execution. Disallow owner to withdraw the NFT before thedrawTimelock
is expired.The text was updated successfully, but these errors were encountered: