https://github.com/Cyfrin/2023-12-Voting-Booth/blob/main/src/VotingBooth.sol#L168-L212
The VotingBooth::_distributeRewards() does not keep track of the contract's balance and does not provide a way for that balance to be withdrawn, resulting in the balance being trapped in the contract forever.
The above is the function as provided in the case study. It can be seen that when totalVotesAgainst < totalVotesFor
which is the else
above, no provision was made to keep track of this balance and also refund the balance back to the owner. The test below when ran also further explains this;
when this is ran, it shows the balance in the VotingBooth contract which signifies the amount that would be stuck in the contract. A getVotefFor() and totalVotesAgainst function was added to the VotingBooth and returns the length of voterfor and votedagainst.
High. Loss of funds.
Manual Review
Keep track of the amount(this amount is the total of those who voted against the proposal), and send this amount to the s_creator.
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.