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

`ChoosingRam::isRamSelected` is not updated

Summary

ChoosingRam::isRamSelected is not updated when a ram is selected in the ChoosingRam::increaseValuesOfParticipants function.

Vulnerability Details

The isRamSelected variable keeps track of whether a ram has been selected or not but it doesn't get updated in the ChoosingRam::increaseValuesOfParticipants function when a ram is selected.

Code
function test_IsRamSelectedNotUpdated() public Moreparticipants {
vm.startPrank(player1);
choosingRam.increaseValuesOfParticipants(0, 1);
choosingRam.increaseValuesOfParticipants(0, 1);
choosingRam.increaseValuesOfParticipants(0, 1);
choosingRam.increaseValuesOfParticipants(0, 1);
choosingRam.increaseValuesOfParticipants(0, 1);
vm.stopPrank();
assertEq(ramNFT.getCharacteristics(1).isJitaKrodhah, true);
assertEq(ramNFT.getCharacteristics(1).isDhyutimaan, true);
assertEq(ramNFT.getCharacteristics(1).isVidvaan, true);
assertEq(ramNFT.getCharacteristics(1).isAatmavan, true);
assertEq(ramNFT.getCharacteristics(1).isSatyavaakyah, true);
assertEq(choosingRam.selectedRam(), player2);
// --- isRamSelected is not set to true after ram has been selected ----------
assertNotEq(choosingRam.isRamSelected(), true);
// ------ The function selectRamIfNotSelected still runs when a ram has been selected -------
vm.warp(1728691200 + 1);
vm.startPrank(organiser);
choosingRam.selectRamIfNotSelected();
vm.stopPrank();
//---- The selected Ram has been changed ----------
assertEq(choosingRam.selectedRam(), player3);
assertEq(choosingRam.isRamSelected(), true);
}

Impact

Functions depending on the ChoosingRam::RamIsNotSelected modifier will return wrong values when a ram is selected through the ChoosingRam::increaseValuesOfParticipantsParticipants function.

  • ChoosingRam::increaseValuesOfParticipantsParticipants can still be called after a ram has been selected.

  • ChoosingRam::selectRamIfNotSelected can still be called after a ram has been selected using the ChoosingRam::increaseValuesOfParticipantsParticipants function.

  • Dussehra::killRavana will not run because it depends on the value of ChoosingRam::RamIsNotSelected modifier which is incorrect.

  • Dussehra::withdraw will not run because it depends on the value of ChoosingRam::RamIsNotSelected modifier which is incorrect.

Tools Used

Manual Analysis

Recommendations

Update the isRamSelected variable after selecting a ram in the ChoosingRam::increaseValuesOfParticipantsParticipants function.

} else if (ramNFT.getCharacteristics(tokenIdOfChallenger).isSatyavaakyah == false){
ramNFT.updateCharacteristics(tokenIdOfChallenger, true, true, true, true, true);
selectedRam = ramNFT.getCharacteristics(tokenIdOfChallenger).ram;
+ isRamSelected = true;
}
} else if (ramNFT.getCharacteristics(tokenIdOfAnyPerticipent).isSatyavaakyah == false){
ramNFT.updateCharacteristics(tokenIdOfAnyPerticipent, true, true, true, true, true);
selectedRam = ramNFT.getCharacteristics(tokenIdOfAnyPerticipent).ram;
+ isRamSelected = true;
}
Updates

Lead Judging Commences

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

`isRamSelected` is not set

Support

FAQs

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