Skip to content
Business logic Audit finding Beginner

Bool check wrong in registerGauge

The registerGauge function in PoolVoter contains an inverted boolean check on the isPool mapping, so a pool that is not yet registered is skipped instead of added. As a result, pools can never be successfully registered, which prevents governance voting on gauges for those pools.

offside0011 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

28910 - [SC - High] Bool check wrong in registerGauge

Submitted on Mar 1st 2024 at 17:07:59 UTC by @offside0011 for Boost | ZeroLend

Report ID: #28910

Report type: Smart Contract

Report severity: High

Target: https://github.com/zerolend/governance

Impacts:

  • Manipulation of governance voting result deviating from voted outcome and resulting in a direct change from intended effect of original results

Description

Brief/Intro

registerGauge function has a boolean value check written incorrectly, causing the pool to never be registered.

Vulnerability Details

in the function registerGauge, the if bool check is wrong,

 mapping(address => bool) public isPool; // pool => bool


if (!isPool[_asset]) {
    _pools.push(_asset);
    isPool[_asset] = true;
}
// register the gauge in the factory
  const gauges = await factory.gauges(lending.erc20.target);
  await poolVoter.registerGauge(lending.erc20.target, gauges.splitterGauge);

Impact Details

lead to pools will never be success registered

References

https://github.com/zerolend/governance/blob/main/contracts/voter/PoolVoter.sol#L136

Proof of concept

function testEXP() public {

    address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
    deal(address(stake), address(owner), 1 ether);
    vm.startPrank(owner);
    poolVoter.registerGauge(address(1), address(11111));
    console.log(poolVoter.length());

    poolVoter.registerGauge(address(3), address(22222));
    console.log(poolVoter.length());

}

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

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 negation in the isPool check is inverted, so the push and flag update only run for pools already marked as registered.

Impact

Pools will never be successfully registered, so governance voting results for those pools cannot be produced as intended.

What the attacker needed

None

The fix

The boolean condition should be corrected so that a pool is added when it is not already registered.

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 keeps a list of pools and a true/false flag saying whether each pool is already in the list. The code meant to add a new pool only when the flag is false, but the condition is written the wrong way round, so new pools are never added. This means the governance system cannot register or vote on those pools.

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 offside0011

View all

4 more disclosed reports, best first.

More from ZeroLend

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.