Closed code423n4 closed 1 year ago
gzeon-c4 marked the issue as primary issue
tbh I don't think this is an issue but wait for sponsor review
I would argue this is not an issue.
If we were to store the raffle winner upon response from chainlink
This to me feels that the winner of the owner of the NFT and the NFT can be freely traded until the claim is processed for the NFT – if you have the NFT up for sale that's the decision of the user. Since we use 3rd party contracts here there isn't a way to prevent trading – it could be integrated to the drawing contract to freeze trading when the raffle results have come back.
@emrecolako can weigh in
Agreed with @iainnash, it's 100% user's decision to put the NFT up for sale. We cannot prevent that from happening if they want to.
iainnash marked the issue as sponsor disputed
gzeon-c4 marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2022-12-forgeries/blob/fc271cf20c05ce857d967728edfb368c58881d85/src/VRFNFTRandomDraw.sol#L282
Vulnerability details
Impact
The winner in the NFT raffle may be frontrun if he has listed his NFT for sale on a marketplace, stealing his raffle NFT.
Proof of Concept
A new
VRFNFTRandomDraw
Clone contract is deployed usingmakeNewDraw
, with some NFT collection asdrawingToken
and another astoken
. Let's say thetoken
is more valuable than some of thedrawingToken
NFTs. The owner callsstartDraw
to start the raffle draw and the winner is owner of, for example,drawingToken
id = 45. The winner has listed his NFT for sale on OpenSea. Frontrun scenario: Malicious attacker deploys a contract, which in one transaction buys the NFT from the winner on OpenSea, callswinnerClaimNFT
, and optionally sells the bought NFT back, profiting a free raffle NFT.Tools Used
VS Code, Forge
Recommended Mitigation Steps
Store the current raffle winner in a storage variable
raffleWinner
inVRFNFTRandomDraw.sol
, on callingstartDraw
orredraw
. Check against that variable on call tohasUserWon(user)
.