NounsDAOV3Proposals.cancel() should allow to cancel the proposal of the Expired state
The cancel function in NounsDAO's governance contract does not allow cancelling proposals in the Expired state, but the Expired state is not final because it depends on the timelock's GRACE_PERIOD, which can be changed by an upgrade. If the grace period is extended, an expired proposal can become queued again, and an attacker could then execute it if they fund the timelock.
Submitted by cccz
cancel() does not allow to cancel proposals in the final states Canceled/Defeated/Expired/Executed/Vetoed.
function cancel(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external {
NounsDAOStorageV3.ProposalState proposalState = stateInternal(ds, proposalId);
if (
proposalState == NounsDAOStorageV3.ProposalState.Canceled ||
proposalState == NounsDAOStorageV3.ProposalState.Defeated ||
proposalState == NounsDAOStorageV3.ProposalState.Expired ||
proposalState == NounsDAOStorageV3.ProposalState.Executed ||
proposalState == NounsDAOStorageV3.ProposalState.Vetoed
) {
revert CantCancelProposalAtFinalState();
}
The Canceled/Executed/Vetoed states are final because they cannot be changed once they are set.
The Defeated state is also a final state because no new votes will be cast (stateInternal() may return Defeated only if the objectionPeriodEndBlock is passed).
But the Expired state depends on the GRACE_PERIOD of the timelock, and GRACE_PERIOD may be changed due to upgrades. Once the GRACE_PERIOD of the timelock is changed, the state of the proposal may also be changed, so Expired is not the final state.
} else if (block.timestamp >= proposal.eta + getProposalTimelock(ds, proposal).GRACE_PERIOD()) {
return NounsDAOStorageV3.ProposalState.Expired;
} else {
return NounsDAOStorageV3.ProposalState.Queued;
Consider the following scenario:
- Alice submits proposal A to stake 20,000 ETH to a DEFI protocol, and it is successfully passed, but it cannot be executed because there is now only 15,000 ETH in the timelock (consumed by other proposals), and then proposal A expires.
- The DEFI protocol has been hacked or rug-pulled.
- Now proposal B is about to be executed to upgrade the timelock and extend
GRACE_PERIOD(e.g.,GRACE_PERIODis extended by 7 days from V1 to V2). - Alice wants to cancel Proposal A, but it cannot be canceled because it is in Expired state.
- Proposal B is executed, causing Proposal A to change from Expired to Queued.
- The malicious user sends 5000 ETH to the timelock and immediately executes Proposal A to send 20000 ETH to the hacked protocol.
Proof of Concept
Recommended Mitigation Steps
Consider adding a proposal expiration time field in the Proposal structure.
function queue(NounsDAOStorageV3.StorageV3 storage ds, uint256 proposalId) external {
require(
stateInternal(ds, proposalId) == NounsDAOStorageV3.ProposalState.Succeeded,
'NounsDAO::queue: proposal can only be queued if it is succeeded'
);
NounsDAOStorageV3.Proposal storage proposal = ds._proposals[proposalId];
INounsDAOExecutor timelock = getProposalTimelock(ds, proposal);
uint256 eta = block.timestamp + timelock.delay();
for (uint256 i = 0; i < proposal.targets.length; i++) {
queueOrRevertInternal(
timelock,
proposal.targets[i],
proposal.values[i],
proposal.signatures[i],
proposal.calldatas[i],
eta
);
}
proposal.eta = eta;
+ proposal.exp = eta + timelock.GRACE_PERIOD();
...
- } else if (block.timestamp >= proposal.eta + getProposalTimelock(ds, proposal).GRACE_PERIOD()) {
+ } else if (block.timestamp >= proposal.exp) {
return NounsDAOStorageV3.ProposalState.Expired;
eladmallel (Nouns DAO) acknowledged and commented:
Agree, it’s possible due to a change in executor’s grace period to move from Expired back to Queued. However, since a grace period change is a rare event, we think this is very low priority and we won’t fix.
gzeon (judge) decreased severity to Low/Non-Critical
eladmallel (Nouns DAO) commented:
We think it would be great to include this issue in the report (at medium severity).
@eladmallel - Changing the
GRACE_PERIODis an admin change, which besides misconfiguration is out-of-scope, it is as you described is a rare event. Having a malicious proposal which is passed that got expired is also a rare event. Having a changedGRACE_PERIODthat just long enough to make such a malicious proposal become queued is a very rare event, assuming governance is not completely compromised already.That said, I am ok with this being Medium risk since this is clearly in scope + can be Medium risk with some assumption (tho extreme imo but is subjective), and I would recommend for a fix accordingly. Please let me know if that’s what you want, thanks!
eladmallel (Nouns DAO) commented:
Thank you @gzeon. We all agree the odds of the risk materializing is low, we just felt like this was a nice find, and honestly mostly motivated by wanting the warden who found this to have a win :)
It’s not a deal breaker for us if it’s in the report or not, just wanted to express our preference.
Thank you for sharing more of your thinking, it’s helpful!
Low Likelihood + High Severity is generally considered Medium, which is an edge case that fits the medium risk. Another thing I would say is that the proposal doesn’t need to be malicious, as I said in the attack scenario where the proposal is normal but expires due to inability to execute for other reasons ( contract balance insufficient, etc.).
Changing the
GRACE_PERIODis an admin change, which besides misconfiguration is out-of-scope, it is as you described is a rare event. Having a malicious proposal which is passed that got expired is also a rare event. Having a changedGRACE_PERIODthat just long enough to make such a malicious proposal become queued is a very rare event, assuming governance is not completely compromised already.
gzeon (judge) increased severity to Medium and commented:
@cccz - True, but this is also marginally out-of-scope since an admin action is required, and one may argue it is a misconfiguration if you increase
GRACE_PERIODso much that it revive some old passed buggy proposal.But given this is marginal and on sponsor’s recommendation, I will upgrade this to Medium.
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 Expired state is treated as final for cancellation, but it is derived from a mutable grace period, so it can revert to Queued if the grace period is extended.
Impact
If the grace period is extended, an expired proposal could be revived and executed, potentially sending funds to a compromised protocol; the report notes this requires a rare admin change and is considered low priority by the sponsor.
What the attacker needed
A passed proposal that expires due to insufficient timelock…; An admin change to extend the timelock's grace period; The proposal's target is compromised or malicious; Attacker can fund the timelock and execute the proposal
The fix
The proposal suggests adding an expiration timestamp field to the Proposal struct and using it to determine the Expired state, so that it cannot be reversed by a grace period change.
How it was found
- Alice submits a proposal that passes but cannot be executed due to insufficient funds in the timelock, so it expires.
- The target protocol of the proposal is hacked or rug-pulled.
- A separate proposal to upgrade the timelock and extend the grace period is about to be executed.
- Alice wants to cancel her expired proposal but cannot because it is in the Expired state.
- The upgrade proposal executes, changing the grace period and causing Alice's proposal to become Queued again.
- A malicious user sends enough funds to the timelock and immediately executes Alice's proposal, sending funds to the hacked protocol.
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 proposal that has passed can be queued for execution, but only within a certain time window called the grace period. If that window passes, the proposal is marked as expired and cannot be cancelled. However, the grace period can be changed by an admin upgrade. If the grace period is extended, an expired proposal might become executable again, and someone could then carry it out, potentially causing harm if the proposal was risky.
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.