When a user enters a battle as a challenger (2nd player on stage), RapBattle::goOnStageOrBattle
does not check whether the challenger actually has the NFT corresponding to the submitted ID. Conseqently, challengers can battle without having a rapper NFT, or can enter a battle with an NFT that they are staking in the Streets
contract.
To participate in a battle, users need to call RapBattle::goOnStageOrBattle
and as arguments to this function, they need to provide
(1) the ID of one of their rapper NFTs and
(2) the amount of CRED
tokens they intend to wager.
However,goOnStageOrBattle
does not check whether the challenger actually holds the NFT. Conseqently, challengers can battle without having a rapper NFT, or with an NFT that they are actively staking.
The challenger can cheat the system and is in an unfair advantage. For example, they can actively stake their NFT and enter the the battle with its ID.
Consider the following scenario:
Defender calls RapBattle::goOnStageOrBattle
, and submits (1) the ID of one of its (not staked) rapper NFTs and (2) some amount of its CRED
balance as a bet.
Defender's NFT and amount of CRED
tokens submitted to the battle are transferred to RapBattle
.
Challenger calls RapBattle::goOnStageOrBattle
, but submits the ID of an NFT that he actively stakes (does not techically hold it), and submits the same bet amount as the defender.
The battle concludes without an issue. Assuming that the defender wins, the challenger's bet is transferred to the defender. All this time, however, the challenger was able to keep staking his NFT and accrue staking rewards.
Insert the following piece of code in OneShotTest.t.sol
:
and test it by executing forge test --mt test_challengerCanBattleWithoutHavingAnNft
.
Output:
Manual review, Foundry.
Before starting the battle, check whether the challenger actually has the NFT belonging to the ID he submitted to the 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.