There maybe a scenario when no one votes for any of the Martenitsa Token, and due to missing checks inside MartenitsaVoting::announceWinner
, the producer with token id - 0 will be announced as winner and will get 1 Health Token.
The vulnerability is present in the announceWinner
function in MartenitsaVoting
contract where it fails to check whether the final winnerTokenId decided has votes which are greater than 0.
Due to this missing check, for the case when no one votes for any token listing, leads to producer with tokenId - 0 being declared as winner and receiving 1 Health Token.
Thus, that producer will be declared as winner and will also received Health Token even though the votes were 0.
Producer with token id - 0 will be declared winner and receive 1 Health Token.
Add the test in the file: test/MartenitsaVoting.t.sol
Run the test:
Manual Review, Foundry Unit Test
Revert in case the maxVotes after calculation comes out to be 0 which represents no one voted.
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.