Skip to content
Smart contracts Audit finding Intermediate

VRFNFTRandomDraw admin can prevent created or started raffle from taking place

The admin/owner of a raffle contract can start a draw in a way that prevents the random number oracle from ever fulfilling it, for example by supplying an invalid key hash or ensuring the VRF subscription lacks funds. This allows the owner to avoid paying out the reward NFT while still appearing to start the raffle.

9svR6w Follow with deliriusz, BAHOZ and 4 others

Originally disclosed on Code4rena

Submitted by 9svR6w, also found by deliriusz, BAHOZ, 0xdeadbeef0x, trustindistrust, gasperpre, and codeislight

https://github.com/code-423n4/2022-12-forgeries/blob/fc271cf20c05ce857d967728edfb368c58881d85/src/VRFNFTRandomDraw.sol#L173

https://github.com/code-423n4/2022-12-forgeries/blob/fc271cf20c05ce857d967728edfb368c58881d85/src/VRFNFTRandomDraw.sol#L162-L168

Impact

The admin/owner of VRFNFTRandomDraw can startDraw() a raffle, including emitting the SetupDraw event, but in a way that ensures fulfillRandomWords() is never called. For example:

In addition, the owner/admin could simply avoid ever calling startDraw() in the first place.

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.

Recommended Mitigation Steps

Depending on the desired functionality with respect to the raffle owner, a successful callback to fulfillRandomWords() could be a precondition of the admin/owner reclaiming the reward NFT. This would help ensure the owner does not create raffles that they intend will never pay out a reward.

iainnash (Forgeries) confirmed


The original report as published on Code4rena, by 9svR6w. 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.

How it worked

Root cause

Likely the contract does not validate that the VRF key hash is correct or that the subscription has sufficient funds before starting the draw, and it does not require a successful random number callback before the owner can reclaim the prize.

Impact

The raffle owner can start a raffle that will never complete, so the reward NFT is never awarded, while the owner may still reclaim it.

What the attacker needed

Attacker is the raffle admin/owner; raffle uses Chainlink VRF

The fix

A successful callback to `fulfillRandomWords()` should be a precondition for the admin/owner to reclaim the reward NFT, ensuring the owner cannot create raffles intended never to pay out.

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.

A raffle contract lets an owner start a draw, but the winner is chosen by an external random number service. The owner can start the draw with settings that make the random number service fail, so the raffle never finishes and the prize is never awarded. This means the owner can pretend to run a raffle without ever giving away the prize.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 9svR6w

View all

1 more disclosed report, best first.

More from Forgeries contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.