Skip to content
Business logic Audit finding Intermediate

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.

codexploder Follow

Originally disclosed on Code4rena

Submitted by codexploder

https://github.com/Plex-Engineer/lending-market/blob/755424c1f9ab3f9f0408443e6606f94e4f08a990/contracts/Governance/GovernorBravoDelegate.sol#L135

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

  1. The _initiate function sets initialProposalId = proposalCount;
  2. Now lets say proposal count was 5 so initialProposalId and proposalCount are both set to 5
  3. Now lets say state function is called on proposal id 2
  4. The require condition checks proposalCount >= proposalId && proposalId > initialProposalId
  5. 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.


The original report as published on Code4rena, by codexploder. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. The _initiate function sets initialProposalId = proposalCount.
  2. Assume proposalCount was 5, so both initialProposalId and proposalCount are 5.
  3. Call the state function on proposal id 2.
  4. The require condition checks proposalCount >= proposalId && proposalId > initialProposalId.
  5. 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.

More by codexploder

View all

3 more disclosed reports, best first.

More from Canto

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.