Skip to content
Business logic Audit finding Intermediate

Tokens are pulled from users without verifying pool status contrary to requirement

The adjust_position_internal function does not check whether the liquidity pool is enabled before taking tokens from users, unlike update_position_internal. An attacker could supply liquidity to a disabled pool, contrary to the documented requirement.

Tigerfrake Follow with DadeKuma

Originally disclosed on Code4rena

Submitted by Tigerfrake, also found by DadeKuma

Both the update_position_internal() and adjust_position_internal() functions are responsible for managing token positions, which involves taking tokens from users. However, there is a critical inconsistency in how each function verifies the operational status of the liquidity pool before performing token transfers from the user.

update_position_internal() - checks if the pool is enabled before taking tokens from the user.

            // if we're TAKING, make sure that the pool is enabled.
            assert_or!(pool.enabled.get(), Error::PoolDisabled);
            ---SNIP---
            erc20::take(pool_addr, token_0.abs_pos()?, permit_0)?;
            erc20::take(FUSDC_ADDR, token_1.abs_pos()?, permit_1)?;

adjust_position_internal() - does not explicitly check whether the pool is enabled before proceeding.

    let (amount_0, amount_1) =
            self.pools
                .setter(pool)
                .adjust_position(id, amount_0_desired, amount_1_desired)?;
    ---SNIP---
    erc20::take(pool, amount_0, permit_0)?;
    erc20::take(FUSDC_ADDR, amount_1, permit_1)?;

First, it calls self.pools.setter(pool).adjust_position(...) which has the following comment:

    // [update_position] should also ensure that we don't do this on a pool that's not currently running
    self.update_position(id, delta)

The comment in the adjust_position() function implies that a check for the pool’s operational state is necessary and should be enforced in update_position(). However, update_position() function does not make such enforcement as it does not check for pool status.

Impact

Users could unintentionally have their tokens adjusted or transferred to a pool that is not operational which is not in accordance with protocol requirement. This also exposes users to risks in the event that there are potential issues with the pool.

Recommended Mitigation Steps

Modify the adjust_position_internal() function to include a status check before executing the position adjustment:

    // Ensure the pool is enabled before making any adjustments
+   assert_or!(pool.enabled.get(), Error::PoolDisabled);

af-afk (Superposition) acknowledged and commented via duplicate Issue #4:

We made the decision that we were going to allow this functionality for now. The reason being that in a programmatic context, the pool can be controlled to be enabled and disabled depending on the broader environment. We use this for example with 9lives to prevent trading of a market that’s expired, in lieu of remembering ownership at different time points of the asset. We made the decision that allowing people to supply liquidity could be useful in the future, and for this reason we also allowed supplying liquidity to a frozen pool as well.

0xsomeone (judge) commented via duplicate Issue #4:

The submission claims that an issue submitted in the original audit was not resolved properly; however, the Sponsor’s choice to acknowledge the issue does not contradict the original issue’s acceptance. As this audit is a follow-up one, it would have been helpful to discuss with the Sponsor directly about their intentions on how to resolve issue #31 of the original audit.

I believe that the issue is invalid based on the Sponsor’s intentions.

DadeKuma (warden) commented via duplicate Issue #4:

@0xsomeone - The original issue was fixed, but it introduced another bug (this issue).

Code documentation clearly states that adding liquidity to disabled pools shouldn’t be possible:

Requires the pool to be enabled unless removing liquidity. Moreover, it’s actually not possible to add liquidity to disabled pools by using the following path, like the documentation suggests:

update_position_C_7_F_1_F_740 > update_position_internal

But it is still possible by using the path described in this issue: incr_position_E_2437399 > adjust_position_internal > adjust_position > update_position

Even if the documentation states that this shouldn’t be possible here:

// [update_position] should also ensure that we don’t do this on a pool that’s not currently // running

This is clearly a discrepancy, and I strongly believe this is a valid issue based on the information available during the audit.

0xsomeone (judge) commented via duplicate Issue #4:

@DadeKuma - I believe the discrepancies between the documentation and the implementation are adequate to merit a proper medium-risk vulnerability rating and have re-instated it so.

af-afk (Superposition) commented:

Fixed here and here.


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

Users could unintentionally have their tokens adjusted or transferred to a pool that is not operational, which is not in accordance with protocol requirements.

What the attacker needed

A disabled pool; user interacts with adjust_position

The fix

The issue was fixed by adding a pool status check in adjust_position_internal.

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 is a smart contract where users deposit tokens. The protocol requires that pools be enabled before users add funds. One function skipped this check, so users could add funds to a disabled pool.

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 Tigerfrake

View all

4 more disclosed reports, best first.

More from Superposition

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.