Skip to content
Business logic Audit finding Intermediate

WhitelistPeriodManager : Improper state handling of exclusion removals

The contract does not update total liquidity mappings when an address is removed from the exclusion list, so later withdrawals by that address can fail with a subtraction overflow. An attacker cannot directly exploit this, but a legitimate user could be prevented from withdrawing staked tokens if the owner removes the exclusion.

hickuphh3 Follow

Originally disclosed on Code4rena

Submitted by hickuphh3, also found by throttle

WhitelistPeriodManager.sol#L178-L184 WhitelistPeriodManager.sol#L115-L125

The totalLiquidity and totalLiquidityByLp mappings are not updated when an address is removed from the isExcludedAddress mapping. While this affects the enforcement of the cap limits and the getMaxCommunityLpPositon() function, the worst impact this has is that the address cannot have liquidity removed / transferred due to subtraction overflow.

In particular, users can be prevented from withdrawing their staked LP tokens from the liquidity farming contract should it become non-excluded.

Proof of Concept

  • Assume liquidity farming address 0xA is excluded
  • Bob stakes his LP token
  • Liquidity farming contract is no longer to be excluded: setIsExcludedAddressStatus([0xA, false])
  • Bob attempts to withdraw liquidity → reverts because totalLiquidityByLp[USDC][0xA] = 0, resulting in subtraction overflow.
// insert test case in Withdraw test block of LiquidityFarming.tests.ts
it.only('will brick withdrawals by no longer excluding farming contract', async () => {
  await farmingContract.deposit(1, bob.address);
  await wlpm.setIsExcludedAddressStatus([farmingContract.address], [false]);
  await farmingContract.connect(bob).withdraw(1, bob.address);
});

// results in
// Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)

Recommended Mitigation Steps

The simplest way is to prevent exclusion removals.

function setIsExcludedAddresses(address[] memory _addresses) external onlyOwner {
  for (uint256 i = 0; i < _addresses.length; ++i) {
    isExcludedAddress[_addresses[i]] = true;
    // emit event
    emit AddressExcluded(_addresses[i]);
  }
}

ankurdubey521 (Biconomy) confirmed

pauliax (judge) decreased severity to Medium and commented:

Great find, but I think it should be of Medium severity because it requires an external condition, the owner should stop excluding the contract, and also in case that happens, function setIsExcludedAddresses can be used to exclude this address again so the funds are not stuck forever in this case.


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

Root cause

Likely the exclusion-removal function does not adjust the total liquidity counters that were previously skipped for excluded addresses, leaving them inconsistent for future withdrawals.

Impact

Users could be prevented from withdrawing staked LP tokens if the owner removes an address from the exclusion list, though the owner can re-exclude the address to restore withdrawals.

What the attacker needed

Owner removes an address from exclusion; user has staked LP tokens

The fix

The simplest mitigation is to prevent exclusion removals entirely, so addresses can only be added to the exclusion list and never removed.

How it was found

  1. Assume the liquidity farming contract address is excluded.
  2. Bob stakes his LP token.
  3. The owner removes the farming contract from the exclusion list.
  4. Bob tries to withdraw his liquidity and the transaction reverts with a subtraction overflow.

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.

This is a smart contract bug where a list of 'excluded' addresses is used to skip some accounting. When an address is taken off that list, the contract's internal totals are not corrected, so later subtraction can go below zero and the transaction fails. The result is that a user might be unable to withdraw their tokens until the owner adds the address back to the exclusion list.

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.