Summary
ContestManage::createContest
doesn't check if ERC20 address is a valid address with an address(0) check
Vulnerability Details
This could be observed in the following code snippet:
function createContest(address[] memory players, uint256[] memory rewards, IERC20 token, uint256 totalRewards)
public
onlyOwner
returns (address)
{
Pot pot = new Pot(players, rewards, token, totalRewards);
contests.push(address(pot));
contestToTotalRewards[address(pot)] = totalRewards;
return address(pot);
}
Impact
A pot with an invalid ERC20 could be created
Tools Used
Manual Review
Recommendations
Add a zero check at the beginning of the createContest function
function createContest(address[] memory players, uint256[] memory rewards, IERC20 token, uint256 totalRewards)
public
onlyOwner
returns (address)
{
// Create a new Pot contract
+ require(address(token) != address(0));
Pot pot = new Pot(players, rewards, token, totalRewards);
contests.push(address(pot));
contestToTotalRewards[address(pot)] = totalRewards;
return address(pot);
}