The RapBattle::goOnStageOrBattle function allows a user to initiate a battle against theirself by calling the function twice with different or the same tokenId.
The RapBattle smart contract allows a user to initiate a battle against theirself by calling the goOnStageOrBattle function twice with different or the same token IDs but the same bet amount.
The RapBattle::goOnStageOrBattle function doesn't check if the address of the defender is not equal to the address of the challenger. That allows to someone to make a battle with theirself. Moreover, the provided tokenId also can be the same.
The following test function testGoOnStageOrBattleSameUser shows the following scenario: The user (Alice) has minted two rapper tokens. The user calls the function RapBattle::goOnStageOrBattle twice and receives the defender and challenger role. In that case the user will have sure win for one of the tokens. You can execute this test function with foundry command:
forge test --match-test "testGoOnStageOrBattleSameUser" -vvvvv
Manual Review, Foundry
Modify the RapBattle::goOnStageOrBattle function to include a check that prevents the msg.sender from initiating a battle if there is already the defender. This can be done by adding a require statement:
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.