Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Valid

Challenger and participant can be same, results in challenger wins everytime

Summary

th expected nft charateristics update logic must happen randomly by choosing either challenger or participant, but there is a bug by which both participant and challenger can be same resulting in always winning of caller/players.

Vulnerability Details

Place below code in Dussehra.t.sol anf run forge test --mt test__ChallengerIsParticipant

function test__ChallengerIsParticipant() public participants {
assertEq(ramNFT.getCharacteristics(0).isJitaKrodhah, false);
vm.startPrank(player1);
choosingRam.increaseValuesOfParticipants(0, 0);
vm.stopPrank();
assertEq(ramNFT.getCharacteristics(0).isJitaKrodhah, true);
}

Impact

Unfair advantage for players to always win

Tools Used

Recommendations

Place below code changes in ChoosingRam.sol

+ error ChoosingRam__ChallengerAndParticipantCantBeSame
function increaseValuesOfParticipants(uint256 tokenIdOfChallenger, uint256 tokenIdOfAnyPerticipent)
public
RamIsNotSelected
{
+ if(tokenIdOfChallenger == tokenIdOfAnyPerticipent){
+ revert ChoosingRam__ChallengerAndParticipantCantBeSame();
}
}
Updates

Lead Judging Commences

bube Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Challenge themselves

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.