You can flip governance decisions without extending vote duration
A voter can flip a governance decision at the last moment without triggering the vote-extension logic by first sending a vote that exactly cancels the current tally to zero, then sending another vote to change the outcome. This bypasses the intended protection that extends the voting period when a vote is flipped.
Submitted by camden, also found by kirk-baird
The impact here is that a user can, right at the end of the voting period, flip the decision without triggering the logic to extend the vote duration. The user doesn’t even have to be very sophisticated: they can just send one vote in one transaction to go to 0, then in a subsequent transaction send enough to flip the vote.
Proof of Concept
https://github.com/code-423n4/2022-01-behodler/blob/608cec2e297867e4d954a63fecd720e80c1d5ae8/contracts/DAO/LimboDAO.sol#L281 You can send exactly enough fate to send the fate amount to 0, then send fate to change the vote. You’ll never trigger this logic.
On the first call, to send the currentProposalState.fate to 0, (fate + currentFate) * fate == 0, so we won’t extend the proposal state.
Then, on the second call, to actually change the vote, fate * currentFate == 0 because currentFate is 0.
Recommended Mitigation Steps
Make sure that going to 0 is equivalent to a flip, but going away from 0 isn’t a flip.
gititGoro (Behodler) confirmed and commented:
Changing the logic to include this edge case can get a little convoluted. One thing I thought of is to change the condition to currentFatefate<0 && currrentFatecurrentFate>fate*fate but then moving from 0 to positive won’t flip the vote. What about requiring the square of your vote to not equal the currentFate and reverting if not? In other words, your vote needs to either have no flipping impact or clearly be intended to flip, not just to cancel out all other votes.
gititGoro (Behodler) commented:
After some consideration, I’m going to implement the square of votes != currentVote rule as a tie makes no sense in the context of whether to execute.
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
Likely the vote-extension logic only checks if the new vote and the current tally have opposite signs, but when the current tally is zero, the multiplication of the two is zero, so the condition fails to detect a flip.
Impact
An attacker could flip a governance decision at the end of the voting period without extending the vote duration, potentially allowing a decision to pass or fail without giving other voters time to react.
What the attacker needed
Ability to cast votes; voting period near its end
The fix
The project implemented a rule that the square of the new vote must not equal the current tally, preventing a vote from exactly cancelling the current tally to zero.
How it was found
- Send a vote that exactly cancels the current tally to zero.
- Send another vote to change the outcome, which does not trigger the extension logic because the current tally is zero.
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 this voting system, if someone changes their vote in a way that flips the current result, the voting period is supposed to be extended so others can react. The attacker found a way to avoid that extension by first cancelling out all existing votes to make the tally zero, then casting a new vote that changes the outcome. This means they can flip the decision at the very last second without giving others a chance to respond.
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.