Incorrect condition always bound to fail
The Governor contract's state function always fails because the initialProposalId is set equal to proposalCount, making the condition proposalId > initialProposalId impossible for any valid proposal. This prevents the contract from creating new proposals.
Originally disclosed on Code4rena
Submitted by codexploder
The state function check GovernorBravoDelegate.sol#L115 will always fail since proposalId cannot lie in between initialProposalId and proposalCount due to an initialization in _initiate function
Proof of Concept
- The
_initiatefunction sets initialProposalId = proposalCount; - Now lets say proposal count was 5 so initialProposalId and proposalCount are both set to 5
- Now lets say state function is called on proposal id 2
- The require condition checks proposalCount >= proposalId && proposalId > initialProposalId
- This is equivalent to 5>=2 && 5>5, since 5>5 is not true this always fails even though proposal id 2 is correct
Recommended Mitigation Steps
Remove initialProposalId = proposalCount; in the _initiate function.
tkkwon1998 (Canto) disagreed with severity and commented:
This is a bug, but will not lead to any attack or loss of funds. The initiate function will just fail, meaning the timelock admin cannot be set. This should be a 2 (Med Risk) issue.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
The warden has shown how, due to misconfiguration the Governor contract can be prevented from creating new proposals.
Because this is contingent on setup, I think Medium Severity to be more appropriate.
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 initialisation sets initialProposalId equal to proposalCount, so the strict inequality proposalId > initialProposalId can never be satisfied for any proposalId that is also less than or equal to proposalCount.
Impact
The Governor contract can be prevented from creating new proposals, but this does not lead to any attack or loss of funds.
What the attacker needed
Governor contract deployed with _initiate called
The fix
Remove the line initialProposalId = proposalCount; in the _initiate function.
How it was found
- The _initiate function sets initialProposalId = proposalCount.
- Assume proposalCount was 5, so both initialProposalId and proposalCount are 5.
- Call the state function on proposal id 2.
- The require condition checks proposalCount >= proposalId && proposalId > initialProposalId.
- This evaluates to 5>=2 && 5>5, which is false, so the call fails even though proposal id 2 is valid.
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.
A smart contract has a function that checks whether a proposal is valid. The check requires the proposal's ID to be greater than a starting ID, but the starting ID is set to the current count, so no proposal can ever pass. This means the contract cannot create new proposals.
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.