Function goOnStageOrBattle
in contract RapBattle
don't do appropriate checks for _credBet
parameter which leads to stolen Credibility
tokens from users.
Function goOnStageOrBattle
in contract RapBattle
if defender != address(0)
do not check the Credibility
balance of user and allowance from user to RapBattle
to spend Credibility
tokens.
Assume that defender
in the RapBattle
contract equals address(0)
, which means that there is no one on stage right now.
1 First user call RapBattle.goOnStageOrBattle
with some _credBet
.
2 Attacker call RapBattle.goOnStageOrBattle
with the same _credBet
without having it on Credibility
contract.
3 Function RapBattle.__battle
is triggered and then we have the following 2 options:
3.1 defender
is win:
credToken.transferFrom
is reverted because of attacker do not call credToken.approve
with the same value as _credBet
and spender equal address of RapBattle
contract
3.2 defender
is loss:
Attacker stole the defenders tokens without putting at risk his founds in Credibility
contract.
4 An attacker can exploit one or more vulnerabilities along with the described vulnerability to reduce the user's probability of winning to 0% :
4.1 Attacker can send _tokenId
without ownership with the biggest amount from getRapperSkill
which reduces the possibility of winning for the user by 10%
4.2 Attacker can then exploit weakrandomness. Picking salt
for create2
to produce contract with fitting address
that 100% win battle.
In case of usage this vulnerability, 4.1 needs to reduce the number of salt
needed to brute force.
4.3 Even if attacker do not want exploit 4.2 he can keep call RapBattle.goOnStageOrBattle
in the following blocks, until he wins.
Attacker can stole the user Credibility
tokens without putting at risk his Credibility
tokens.
Manual review.
Make the following changes in RapBattle.sol
https://github.com/Cyfrin/2024-02-one-shot/blob/47f820dfe0ffde32f5c713bbe112ab6566435bf7/src/RapBattle.sol#L38C1-L52C6
https://github.com/Cyfrin/2024-02-one-shot/blob/47f820dfe0ffde32f5c713bbe112ab6566435bf7/src/RapBattle.sol#L54C1-L81C6
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.