Skip to content
Business logic Audit finding Intermediate

Incentive Pool can be drained without rebalancing the pool

The depositErc20 function allowed a user to set the destination chain to the same as the source chain and the receiver to themselves, which let them claim the incentive pool reward without actually rebalancing the pool. An attacker with sufficient collateral could repeatedly drain the incentive pool on each chain.

kyliek Follow

Originally disclosed on Code4rena

Submitted by kyliek, also found by Ruhum and WatchPug

LiquidityPool.sol#L149-L173 LiquidityPool.sol#L263-L277

depositErc20 allows an attacker to specify the destination chain to be the same as the source chain and the receiver account to be the same as the caller account. This enables an attacker to drain the incentive pool without rebalancing the pool back to the equilibrium state.

Proof of Concept

This requires the attacker to have some collateral, to begin with. The profit also depends on how much the attacker has. Assume the attacker has enough assets.

In each chain, when the pool is very deficit (e.g. currentLiquidity is much less than providedLiquidity), which often mean there’s a good amount in the Incentive pool after some high valued transfers, then do the following.

  • step 1 : borrow the liquidityDifference amount such that one can get the whole incentivePool.
            uint256 liquidityDifference = providedLiquidity - currentLiquidity;
            if (amount >= liquidityDifference) {
                rewardAmount = incentivePool[tokenAddress];
  • step 2 : call depositErc20() with toChainId being the same chain and receiver being msg.sender.

The executor will call sendFundsToUser to msg.sender. Then a rewardAmount, equivalent to the entire incentive pool (up to 10% of the total pool value), will be added to msg.sender minus equilibrium fee (~0.01%) and gas fee.

In the end, the pool is back to the deficit state as before, the incentive pool is drained and the exploiter pockets the difference of rewardAmount minus fees.

This attack can be repeated on each deployed chain multiple times whenever the incentive pool is profitable (particularly right after a big transfer).

Recommended Mitigation Steps

  • Disallow toChainId to be the source chain by validating it in depositErc20 or in sendFundsToUser validate that fromChainId is not the same as current chain.
  • Require receiver is not msg.sender in depositErc20.

tomarsachin2271 (Biconomy) commented:

If depositor keeps toChainId same as source chain Id, then executor will not pick this deposit transaction on backend as there won’t be any mapping for fromChainId => toChainId, so depositor funds will remain in the source chain if he tries to do it and try to drain the incentive pool.

Although this could happen coz of any bug on the UI, so it’s better to handle these situations on contract itself. It will increase a gas though a bit while depositing. Will consider this point though.

ankurdubey521 (Biconomy) confirmed and commented:

HP-25: C4 Audit Fixes, Dynamic Fee Changes bcnmy/hyphen-contract#42

pauliax (judge) decreased severity to Medium and commented:

It is always good to enforce such things on the contract level itself if possible. While there are some precautions, there still exists a hypothetical attack path so I am leaving this as of medium severity.


The original report as published on Code4rena, by kyliek. 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 contract did not validate that the destination chain differs from the source chain and that the receiver is not the caller, allowing a self-transfer to trigger the incentive reward.

Impact

An attacker could drain the incentive pool on each deployed chain multiple times whenever it is profitable, but the project noted that the backend executor would not pick up such a deposit, so the attack may not work in practice.

What the attacker needed

Attacker has sufficient collateral; pool is in deficit state; incentive pool has funds

The fix

The contract should validate that toChainId is not the source chain and that receiver is not msg.sender; the project confirmed a fix in a pull request.

How it was found

  1. Borrow the liquidityDifference amount so that the whole incentivePool can be claimed.
  2. Call depositErc20() with toChainId set to the same chain and receiver set to msg.sender.
  3. The executor calls sendFundsToUser to msg.sender, adding a rewardAmount equivalent to the entire incentive pool (up to 10% of total pool value) minus fees.
  4. The pool returns to the deficit state, the incentive pool is drained, and the attacker keeps the reward minus fees.

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 liquidity pool pays a reward when someone moves funds to another chain to help balance it. The bug let a user pretend to move funds by setting the same chain as both source and destination, so they got the reward without helping. They could repeat this to take all the reward 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 kyliek

View all

3 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.