Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: high

If there are multiple tokens for rewards in a competition, it may cause other tokens to be locked in the contract

Summary

If there are multiple tokens for rewards in a competition, it may cause other tokens to be locked in the contract

Vulnerability Details

According to the document description:

@notice The constructor will set the whitelist tokens. e.g. USDC, JPYCv1, JPYCv2, USDT, DAI

Let's imagine a scenario, if sponsors and organizers provide different token rewards for the competition, such as USDC, USDT, DAI. After the competition, the organizer needs to distribute the rewards to the winners.

However, in Distributor._distribute() function The function only allows to specify one token

function _distribute(address token, address[] memory winners, uint256[] memory percentages, bytes memory data)

So the organizer may need to call function deployProxyAndDistribute() multiple times to distribute different token rewards.However,Function _deployProxy() will be called every time function deployProxyAndDistribute() is called, but function _deployProxy() does not check whether the Proxy contract already exists. When the organizer wants to call function deployProxyAndDistribute() for the second time to distribute other token rewards, when the program executes to function _deployProxy() , an exception will be thrown due to the failure of address proxy = address(new Proxy{salt: salt}(implementation));, which will cause the function execution to fail

function _deployProxy(address organizer, bytes32 contestId, address implementation) internal returns (address) {
bytes32 salt = _calculateSalt(organizer, contestId, implementation);
address proxy = address(new Proxy{salt: salt}(implementation));//@audit
return proxy;
}

Impact

If there are multiple tokens for rewards in a competition, it may cause other tokens to be locked in the contract

Tools Used

vs code

Recommendations

I sugguest:

  1. Check if the contractProxy has been deployed in _deployProxy()

  2. The token parameter of Distributor._distribute() can be changed to an array type

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.