Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
howlbot-integration bot opened this issue Nov 4, 2024 · 4 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden M-02 primary issue Highest quality submission among a set of duplicates 🤖_01_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards selected for report This submission will be included/highlighted in the audit report sufficient quality report This report is of sufficient quality

Comments

@howlbot-integration
Copy link

Lines of code

https://github.com/code-423n4/2024-10-superposition/blob/7ad51104a8514d46e5c3d756264564426f2927fe/pkg/seawater/src/lib.rs#L679-L687
https://github.com/code-423n4/2024-10-superposition/blob/7ad51104a8514d46e5c3d756264564426f2927fe/pkg/seawater/src/lib.rs#L716-L738

Vulnerability details

Proof of Concept

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()
This function 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()
This 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);

Assessed type

Other

@howlbot-integration howlbot-integration bot added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value 🤖_01_group AI based duplicate group recommendation bug Something isn't working duplicate-4 edited-by-warden sufficient quality report This report is of sufficient quality labels Nov 4, 2024
howlbot-integration bot added a commit that referenced this issue Nov 4, 2024
@c4-judge
Copy link

alex-ppg marked the issue as unsatisfactory:
Invalid

@c4-judge c4-judge added unsatisfactory does not satisfy C4 submission criteria; not eligible for awards and removed duplicate-4 labels Nov 13, 2024
@c4-judge c4-judge reopened this Nov 20, 2024
@c4-judge c4-judge added primary issue Highest quality submission among a set of duplicates selected for report This submission will be included/highlighted in the audit report labels Nov 20, 2024
@c4-judge
Copy link

alex-ppg marked the issue as selected for report

@c4-judge c4-judge added satisfactory satisfies C4 submission criteria; eligible for awards and removed unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Nov 20, 2024
@c4-judge
Copy link

alex-ppg marked the issue as satisfactory

@af-afk
Copy link

af-afk commented Nov 25, 2024

@C4-Staff C4-Staff added the M-02 label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden M-02 primary issue Highest quality submission among a set of duplicates 🤖_01_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards selected for report This submission will be included/highlighted in the audit report sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

3 participants