Creating a new governance proposal can be prevented by anyone
The proposal ID is derived solely from the proposal data, so an attacker can front-run a legitimate proposal with identical data and then immediately cancel it, causing the original creation to revert with PROPOSAL_EXISTS. This prevents the proposer from creating that exact proposal again without altering the data.
Originally disclosed on Code4rena
Submitted by berndartmueller, also found by CertoraInc, m9800, and scaraven
When creating a new governance proposal, the proposalId is generated by hashing the proposal data (_targets, _values, _calldatas, descriptionHash). To prevent duplicated proposals, the current Governor implementation checks if the proposalId exists already. If it exists, the call will revert with the PROPOSAL_EXISTS error.
Impact
Anyone can prevent others from creating governance proposals by front-running the create proposal transaction with the same data, followed by an immediate call to the Governor.cancel function.
This will prevent creating a proposal with the same proposal data. A proposal creator would have to slightly change the proposal to try to create it again (however, it can be prevented again due to the aforementioned issue).
Proof of Concept
governance/governor/Governor.propose
function propose(
address[] memory _targets,
uint256[] memory _values,
bytes[] memory _calldatas,
string memory _description
) external returns (bytes32) {
[..]
// Compute the description hash
bytes32 descriptionHash = keccak256(bytes(_description));
// Compute the proposal id
bytes32 proposalId = hashProposal(_targets, _values, _calldatas, descriptionHash);
// Get the pointer to store the proposal
Proposal storage proposal = proposals[proposalId];
// Ensure the proposal doesn't already exist
if (proposal.voteStart != 0) revert PROPOSAL_EXISTS(proposalId); // @audit-info Reverts in case the proposals with the same data exists already
[..]
}
governance/governor/Governor.cancel
Cancelling a proposal updates the proposal.canceled boolean property to true. proposal.voteStart is left unchanged (!= 0).
/// @notice Cancels a proposal
/// @param _proposalId The proposal id
function cancel(bytes32 _proposalId) external {
// Ensure the proposal hasn't been executed
if (state(_proposalId) == ProposalState.Executed) revert PROPOSAL_ALREADY_EXECUTED();
// Get a copy of the proposal
Proposal memory proposal = proposals[_proposalId];
// Cannot realistically underflow and `getVotes` would revert
unchecked {
// Ensure the caller is the proposer or the proposer's voting weight has dropped below the proposal threshold
if (msg.sender != proposal.proposer && getVotes(proposal.proposer, block.timestamp - 1) > proposal.proposalThreshold)
revert INVALID_CANCEL();
}
// Update the proposal as canceled
proposals[_proposalId].canceled = true;
// If the proposal was queued:
if (settings.treasury.isQueued(_proposalId)) {
// Cancel the proposal
settings.treasury.cancel(_proposalId);
}
emit ProposalCanceled(_proposalId);
}
Recommended mitigation steps
Consider adding a per-account nonce storage variable (e.g. mapping(address => uint256) internal proposalCreatorNonces; to the Governor contract and include the proposalCreatorNonces[msg.sender]++ nonce within the computed proposal id.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
The Warden has shown how, a motivated attacker can consistently grief the DAO with multiple spam proposals, that front-run the “official” ones, with the goal of cancelling them and preventing them to go through.
This exploit can be performed as long as the attacker has sufficient balance to be a
Proposer.The only saving grace from this finding being a High Severity is that there are ways to avoid the front-running.
Specifically a proposer could:
- Use a private relayer
- Ask a miner / proposer to mine the tx
Additionally, the Proposer could use a contract, which would loop through proposals, by using a source of randomness to try a bunch of new proposals.
Because checking if a proposal exists is cheaper than writing it (2.1k vs 20k to write in a storage slot), the write can eventually come up with one proposal the attacker didn’t perform.
However the remediation requires a new contract, not available at this time.
The reason why this remediation is possible is that the
_descriptionparameter is used to uniquely identify a proposal, this allows to create gibberish strings until we get one that goes through.Because the attack is:
- Possible
- Easy to implement But can be sidestepped, via a fairly complicated process
I think Medium Severity to be appropriate.
Remediation would be to add the proposer address as part of the proposal id identifier.
kulkarohan (Nouns Builder) confirmed
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 proposal ID is computed only from the proposal data, without including the proposer's address or a per-account nonce, so identical proposals from different senders collide.
Impact
An attacker with enough voting weight to meet the proposal threshold can repeatedly block specific proposals, though the proposer could use private relayers or a contract with random descriptions to work around it.
What the attacker needed
Attacker meets proposal threshold; attacker can front-run transactions
The fix
The proposal ID should include the proposer's address or a per-account nonce so that identical proposals from different senders do not collide.
How it was found
- Observe a pending create-proposal transaction with its data.
- Submit an identical proposal transaction with higher gas to be mined first.
- Immediately call the cancel function on the newly created proposal ID.
- The original proposer's transaction then reverts because the proposal ID already exists.
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 system, a governance proposal is identified by a fingerprint made from its contents. If someone else submits the exact same proposal first, the system thinks it already exists and rejects the second attempt. The attacker can then cancel their copy, but the original proposer still cannot create the same proposal again because the cancelled copy leaves a marker that blocks duplicates.
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.