Function getRapperStats
in OneShot
contract not checked that tokenId
is belong to previously minted NFT which leads to the return of incorrect data for non-existent NFTs:
weakKnees, heavyArms, spaghettiSweater is set to false
that leads to incorrect RapBattle.getRapperSkill(uint256 _tokenId)
returns:
1 RapBattle.getRapperSkill(uint256 _tokenId)
returns 50
for just minted rapper.
2 RapBattle.getRapperSkill(uint256 _tokenId)
returns 65
for non-existent rapper.
Assume that defender
getRapperSkill
equal 50 then:
Without using this vulnerability by attacker defender
wins in 50 randoms from 100 // 50% of winning
With using this vulnerability by attacker defender
wins in 50 randoms from 115 // ~43% of winning
Incorrect data leads to confusion users of the system.
Also attacker can use this in conjunction with another vulnerability (RapBattle.goOnStageOrBattle
does not check the ownership of the _tokenId
supplied by challenger
) and increase his chances to win up to 7% without minting and staking rapper.
Add this test to OneShotTest.t.sol
and run via forge test --mt testGetRapperStatsForNotExistingRapper
to see it success.
Output:
Manual review, foundry.
Make the following changes in OneShot.getRapperStats()
https://github.com/Cyfrin/2024-02-one-shot/blob/47f820dfe0ffde32f5c713bbe112ab6566435bf7/src/OneShot.sol#L57C1-L59C6
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.