Skip to content
Business logic Audit finding Intermediate

WhitelistPeriodManager : Improper state handling of exclusion additions

The contract does not update total liquidity mappings when an address with existing liquidity is added to the exclusion list. This causes the cap calculation to overstate available liquidity, preventing other users from providing liquidity.

hickuphh3 Follow

Originally disclosed on Code4rena

Submitted by hickuphh3

WhitelistPeriodManager.sol#L178-L184 WhitelistPeriodManager.sol#L83-L99

The totalLiquidity and totalLiquidityByLp mappings are not updated when an address is added to the isExcludedAddress mapping. This affects the enforcement of the cap limits and the getMaxCommunityLpPositon() function, which implicitly assumes that whitelisted addresses will have 0 liquidity, for addresses with non-zero liquidity at the time of addition to the whitelist.

Proof of Concept

  • Assume the following initial conditions:

    • Alice’s address 0xA is the sole USDC liquidity provider

      • totalLiquidity[USDC] = 500
      • totalLiquidity[USDC][0xA] = 500
    • USDC total cap of 500, ie. perTokenTotalCap[USDC] = 500

  • Exclude Alice’s address 0xA: setIsExcludedAddressStatus([0xA, true])

    • totalLiquidity mappings are unchanged
  • The following deviant behaviour is observed:

    • getMaxCommunityLpPositon() returns 500 when it should return 0

    • All non-excluded addresses are unable to provide liquidity when they should have been able to, as Alice’s liquidity should have been excluded.

      // insert test case in WhitelistPeriodManager.test.ts
      describe.only("Test whitelist addition", async () => {
      it('produces deviant behaviour if excluding address with existing liquidity', async () => {
      await wlpm.setCaps([token.address], [500], [500]);
      await liquidityProviders.connect(owner).addTokenLiquidity(token.address, 500);
      await wlpm.setIsExcludedAddressStatus([owner.address], [true]);
      // 1) returns 500 instead of 0
      console.log((await wlpm.getMaxCommunityLpPositon(token.address)).toString());
      // 2) bob (or other non-excluded addresses) will be unable to add liquidity
      await expect(liquidityProviders.connect(bob).addTokenLiquidity(token.address, 1)).to.be.revertedWith('ERR__LIQUIDITY_EXCEEDS_PTTC');
      });
      });
      

Recommended Mitigation Steps

Check that the address to be excluded is not holding any LP token at the time of exclusion.

// in setIsExcludedAddressStatus()
for (uint256 i = 0; i < _addresses.length; ++i) {
  if (_status[i]) {
    require(lpToken.balanceOf(_addresses[i]) == 0, 'address has existing liquidity');
  }
  ...
}

ankurdubey521 (Biconomy) confirmed

pauliax (judge) commented:

I think it is a different issue than M-15, based on the description it deserves a severity of Medium.


The original report as published on Code4rena, by hickuphh3. 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

Impact

Non-excluded addresses may be unable to provide liquidity because the cap is incorrectly calculated as full.

What the attacker needed

Address has existing liquidity; caller can exclude addresses

The fix

The exclusion function should check that the address holds no LP tokens before excluding it, or update the total liquidity mappings accordingly.

How it was found

  1. Set a total cap for a token.
  2. Have an address add liquidity up to the cap.
  3. Exclude that address via setIsExcludedAddressStatus.
  4. Observe that getMaxCommunityLpPositon returns the cap instead of zero.
  5. Attempt to add liquidity from another address and see it revert with ERR__LIQUIDITY_EXCEEDS_PTTC.

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 tracks how much money each person has put in. When someone is marked as 'excluded' (so their money shouldn't count towards a limit), the contract forgets to subtract their money from the total. This makes the contract think the limit is already full, so other people can't add their money.

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 hickuphh3

View all

43 more disclosed reports, best first.

More from Biconomy - Smart Contract Wallet contest

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.