_voteSucceeded() returns true when againstVotes > forVotes and vice versa
The governance contract's vote success check compared the against-votes tally against the for-votes tally in the wrong order, so a proposal with more against votes than for votes would be considered successful. An attacker could therefore pass a proposal that the majority opposed.
T1MOH Follow with yjrwkk, josephdara and 11 others
Originally disclosed on Code4rena
Submitted by T1MOH, also found by yjrwkk, josephdara, devival, KupiaSec, LaScaloneta, cccz, Iurii3, pep7siup, 0xnev, bytes032, bytes032, skyge, and sces60107
As a result, voting process is broken, as it won’t execute proposals with most of forVotes. Instead, it will execute proposals with most of againstVotes.
Proof of Concept
It returns whether number of votes with support = 1 is greater than with support = 0:
function _voteSucceeded(uint256 proposalId) internal view override returns (bool){
return proposalData[proposalId].supportVotes[1] > proposalData[proposalId].supportVotes[0];
}
However support = 1 means againstVotes, and support = 0 means forVotes:
function proposals(uint256 proposalId) external view returns (...) {
...
forVotes = proposalData[proposalId].supportVotes[0];
againstVotes = proposalData[proposalId].supportVotes[1];
abstainVotes = proposalData[proposalId].supportVotes[2];
...
}
Tools Used
Manual Review
Recommended Mitigation Steps
Swap 1 and 0:
function _voteSucceeded(uint256 proposalId) internal view override returns (bool){
return proposalData[proposalId].supportVotes[0] > proposalData[proposalId].supportVotes[1];
}
Assessed type
Governance
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The indices used in the comparison were swapped: supportVotes[1] (against) was compared as greater than supportVotes[0] (for), instead of the reverse.
Impact
Proposals with a majority of against votes would be executed, while proposals with a majority of for votes would not, breaking the governance process.
What the attacker needed
None
The fix
The comparison should be reversed so that supportVotes[0] (for) is compared as greater than supportVotes[1] (against).
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a voting system, each proposal has a count of votes for it and a count of votes against it. The code that decides whether a proposal passes accidentally checked whether the 'against' count was bigger than the 'for' count, so proposals that most people voted against would be treated as approved.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.