If the winners’ addresses are erroneously set with the zero address, the distribution will result in a loss of funds.
The contract can be successfully deployed with a zero address for the winners (aka supporters), which should not be allowed.
In the contracts, there are specific checks for nonzero address in
the organizer and implementation address: https://github.com/Cyfrin/2023-08-sparkn/blob/main/src/ProxyFactory.sol#L109
the token address:
https://github.com/Cyfrin/2023-08-sparkn/blob/main/src/Distributor.sol#L120
the factory and stadium address:
https://github.com/Cyfrin/2023-08-sparkn/blob/main/src/Distributor.sol#L77
the proxy address:
https://github.com/Cyfrin/2023-08-sparkn/blob/main/src/ProxyFactory.sol#L212
and the whitelisted tokens addresses:
https://github.com/Cyfrin/2023-08-sparkn/blob/main/src/ProxyFactory.sol#L84
But even though there is a specific check that reverts when the winners array length is equal to 0 (https://github.com/Cyfrin/2023-08-sparkn/blob/main/src/Distributor.sol#L125), the winner’s addresses itself are not verified against the zero address.
Consider the following PoC using the HelperContract.t.sol. As mentioned it is possible to make a deployment using the address(0) for the winners as nothing prevents to do it and there is no check implemented; therefore we can make a minor modification to change the variable user1
to address(0)
, where all the actors are declared to test our scenario:
After executing the test where all conditions are met, so the contest should succeed testIfAllConditionsMetThenUsdcSendingCallShouldSuceed
, we get a revert when distributing the prizes because one of the winners is having an address(0), which we know in advance is user1, as this user is used throughout the function test:
Sponsor funds can get lost in contract if winners’ addresses are erroneously set as a zero address.
Static review
There should be zero address checkings in place for the winners (supporters) to prevent loss of funds.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.