In the RapBattle::_battle
function when a defender wins a battle, the contract attempts to transfer the challenger's wagered CRED
tokens to the defender. However, the contract does not ensure that the challenger has approved the RapBattle
contract to transfer their CRED
tokens on their behalf, leading to a failure in executing the token transfer. The defender doesn't receive the prize.
The vulnerability arises from the use of the transferFrom
function without prior assurance that the necessary approval has been granted by the token owner (the challenger in this context). The ERC-20 token standard requires that transferFrom
can only be successfully called if the token owner has explicitly approved the spender (in this case, the RapBattle
contract) to withdraw tokens up to a certain amount.
If the challenger has not approved the RapBattle
contract to transfer their CRED
tokens, the contract's attempt to transfer the wagered tokens to the defender (in the event of the defender's victory) will fail.
Manual review
It is recommended to implement a mechanism that ensures challengers have approved the RapBattle
contract to transfer their wagered CRED
tokens before they can participate in a battle.
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.