RamNFT contract allow the organiser to directly set the characteristics of any ramNFT. This bypasses the ChoosingRam::increaseValuesOfParticipants function and allows the organiser to influence who will be selected as Ram. It breaks the intended functionality of the contract.Description: This weakness unfolds in several steps.
Weak checks at RamNFT:setChoosingRamContract allow the organiser to set choosingRamContract to any contract address. The organiser can do this at any time, also after the Dussehra protocol has been deployed.
Resetting choosingRamContract allows the organiser to call RamNFT:updateCharacteristics through an alternative contract with an alternative functionality.
This alternative contract can, for instance, take a tokenId as input and reset characteristics of a ramNFT.
This can result in this tokenId being selected as Ram.
I did not log this as a high vulnerability because the selectRamIfNotSelected function will always reset selectedRam. See vulnerability [H-5] above.
Impact: By setting characteristics of a ramNFT to true, the protocol can be pushed to select a particular ramNFT as Ram.
Proof of Concept: As noted, this vulnerability unfolds in several steps:
The organiser deploys Dussehra.sol, RamNFT.sol and ChoosingRam.sol as usual.
The organiser sets choosingRamContract to address(ChoosingRam.sol) by calling setChoosingRamContract.
Participants enter the protocol, including the organiser. So far everything is fine.
The organiser then creates an alternative contract that calls selectedRamNFT.updateCharacteristics and can resets characteristics of a ramNFT.
The organiser changes choosingRamContract to the address of the alternative contract.
The organiser calls a function in the alternative contract and changes the characteristics of their ramNFT to true, true, true, true, false.
The organiser changes choosingRamContract back to the address of ChoosingRam.sol.
The organiser calls updateCharacteristics until the last characteristic is turned to true and, with it, their ramNFT is selected as Ram. As four out of five characteristics were set to true, the organiser's ramNFT is almost certainly to be selected as Ram.
Place the following in the Dussehra.t.sol test file, below the CounterTest contract.
Place the following in the CounterTest contract of the Dussehra.t.sol test file.
Recommended Mitigation: Do not allow the choosingRamContract to be changed after initialisation.
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.