The ContestManager
contract in its current form attempts to transfer ERC-20 tokens to Pot
contracts without first ensuring that the necessary approval has been granted. This is a critical issue because the ERC-20 standard requires that any spender must be pre-approved by the token owner before any transfer can be made using transferFrom
.
The fundContest
function in the ContestManager
contract is designed to transfer tokens from the owner to a Pot
contract. However, it lacks the necessary approval step, which is a prerequisite for the transferFrom
method to succeed. The transferFrom
function in the ERC-20 standard (as implemented in OpenZeppelin) relies on an existing allowance set by the owner.
If the fundContest
function attempts to transfer tokens without prior approval, the transaction will fail, resulting in a loss of functionality. This could lead to the inability to fund contests, thereby preventing the contract from being used as intended. This flaw could also lead to a loss of user funds if they are unable to retrieve their tokens after an unsuccessful transfer attempt.
The proof of this vulnerability lies in the interaction between the ContestManager
contract and the ERC-20 token contract. Here is the relevant portion of the OpenZeppelin ERC-20 contract that shows how the transferFrom
function operates:
And the _spendAllowance
function that checks the allowance:
As seen, currentAllowance < value
will cause the transaction to revert if there is not enough allowance. Since the ContestManager
does not have a mechanism to set this allowance, any call to token.transferFrom
will fail unless the owner has manually approved the ContestManager
or Pot
contract to spend their tokens, which is outside the scope of the current contract logic.
_approve
FunctionThe _approve
function is responsible for updating the allowance mapping:
This function is crucial for updating the _allowances
mapping, which is used to keep track of how much a spender is allowed to transfer on behalf of the owner.
Implement an Approval Step: Before attempting to fund a Pot
, add a function to the ContestManager
that calls approve
on the token contract to set the necessary allowance.
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.