Drawing with invalid subscriptionId
is useless
#131
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-101
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-forgeries/blob/fc271cf20c05ce857d967728edfb368c58881d85/src/VRFNFTRandomDraw.sol#L164
Vulnerability details
Impact
When a user creates a drawing, he must specify a
subscriptionId
, which is then used for Chainlink VRF. However, it is never checked if the subscription is valid. Also, it can never be changed. So if the user inputs the wrong ID, the winner can never be drawn.Proof Of Concept
Add this code to
test/VRFNFTRandomDraw.t.sol
. The test will fail withInvalidConsumer()
whenstartDraw
is called. Notice that this is the error that is returned byVRFCoordinatorV2Mock.sol
which is a bit different than the originalVRFCoordinatorV2.sol
. The original contract would revert withInvalidSubscription()
.The above code is just to show what the problem is and it is not a proper test that you would include in your tests. Instead if you decide to fix this problem, I recommend that you add a test like this one:
Recommended Mitigation Steps
Add
subscriptionId
validation toinitialize
function inVRFNFTRandomDraw.sol
. You can validate it by callingVRFCoordinatorV2.getSubscription(subId)
and checking that the owner address is equal to the creator (or some other address that should be responsible for the VRF subscription).The text was updated successfully, but these errors were encountered: