- High: 1
- Medium: 1
- Low: 0
The lack of VotingBooth::withdraw
function locks the token in the contract forever.
Consider the following scenario, there is 5 allowed voters and the threshold of voters required to trigger the reward distribution is 3. Assume the reward is 1 ether and two of the voter votes for the proposal and the other one votes against, the reward for the two for-voter will be:
1st voter: 3333333333333333333 (wei) 2nd voter: 3333333333333333334 (wei)
and the voter votes against will not get any tokens as reward. In this case, there are 3333333333333333333 wei of ether remaining in the contract. However, there is no withdraw function that can take the token out of the contract.
Simple PoC:
function testDistributeAmount() public { // Assume there are 5 allowed voters in total.
vm.prank(address(0x1));
booth.vote(true);
vm.prank(address(0x2));
booth.vote(true);
vm.prank(address(0x3));
booth.vote(false);
console2.log(address(0x1).balance); // 3333333333333333333 wei
console2.log(address(0x2).balance); // 3333333333333333334 wei
console2.log(address(0x3).balance); // 0 wei
console2.log(address(booth).balance); // 3333333333333333333 wei but fail to withdraw
}
Every voting result that totalVotesAgainst < totalVotesFor
but totalVotesFor != totalVotes
will have remaining tokens, and these tokens are unable to transfer to any address, thus locking in the contract.
Manual Review
At the end of the VotingBooth::_distributeReward
funciton, send the remaining ether to the s_creator
or design a withdraw function.
M-01. Incompatibility of Solidity 0.8.23 with Arbitrum: Deployment Failures Due to Unsupported PUSH0 Opcode
Deployment will fail or the execution will have unintended behavior for Solidity version 0.8.23 on Arbitrum Network.
According to the documentation, the contract is intended to be deployed on the Arbitrum network using version 0.8.23: However, the Arbitrum network does not support push0 opcode in the latest Solidity compiler version.
It will lead to compilation error or intended behavior while deployment.
Manual Review
Downgrade to lower version of Solidity such as 0.8.18