Skip to content
Business logic Audit finding Intermediate

Incorrect slippage would result in swap manipulations

The contract calculates the minimum output amount for a Uniswap swap inside the same transaction, using a quote taken after the pool may already have been manipulated. An attacker could front-run the swap to worsen the price, causing the victim to receive fewer tokens than expected.

kodyvim Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

57076 sc high incorrect slippage would result in swap manipulations

Submitted on Oct 23rd 2025 at 09:13:34 UTC by @kodyvim for Audit Comp | Belong

Description

Brief/Intro

Incorrect on-chain slippage calculation enables sandwich/MEV swap manipulation

Vulnerability Details

_swapExact() is used to perform an exact USDC amount swaps to LONG via uniswap and vice versa.

Solidity
function _swapUSDCtoLONG(address recipient, uint256 amount) internal virtual returns (uint256 swapped) {
        PaymentsInfo memory p = belongCheckInStorage.paymentsInfo;
@>      return _swapExact(p.usdc, p.long, recipient, amount);
    }
function _swapLONGtoUSDC(address recipient, uint256 amount) internal virtual returns (uint256 swapped) {
        PaymentsInfo memory p = belongCheckInStorage.paymentsInfo;
        return _swapExact(p.long, p.usdc, recipient, amount);
    }
Solidity
function _swapExact(address tokenIn, address tokenOut, address recipient, uint256 amount)
        internal
        returns (uint256 swapped)
    {
        if (recipient == address(0) || amount == 0) {
            return 0;
        }

        PaymentsInfo memory _paymentsInfo = belongCheckInStorage.paymentsInfo;

        bytes memory path = _buildPath(_paymentsInfo, tokenIn, tokenOut);

        uint256 amountOutMinimum =
            IV3Quoter(_paymentsInfo.swapV3Quoter).quoteExactInput(path, amount).amountOutMin(_paymentsInfo.slippageBps);//@audit-info invalid slippage

        IV3Router.ExactInputParamsV1 memory swapParamsV1 = IV3Router.ExactInputParamsV1({
            path: path,
            recipient: recipient,
            deadline: block.timestamp,
            amountIn: amount,
            amountOutMinimum: amountOutMinimum
        });

        // Reset -> set pattern to support non-standard ERC20s that require zeroing allowance first
        tokenIn.safeApproveWithRetry(_paymentsInfo.swapV3Router, amount);
        try IV3Router(_paymentsInfo.swapV3Router).exactInput(swapParamsV1) returns (uint256 amountOut) {
            swapped = amountOut;
        } catch {
            IV3Router.ExactInputParamsV2 memory swapParamsV2 = IV3Router.ExactInputParamsV2({
                path: path, recipient: recipient, amountIn: amount, amountOutMinimum: amountOutMinimum
            });
            try IV3Router(_paymentsInfo.swapV3Router).exactInput(swapParamsV2) returns (uint256 amountOut) {
                swapped = amountOut;
            } catch {
                revert SwapFailed(tokenIn, tokenOut, amount);
            }
        }

        // Clear allowance to reduce residual approvals surface area
        tokenIn.safeApprove(_paymentsInfo.swapV3Router, 0);

        emit Swapped(recipient, amount, swapped);
    }

The issue is that the minimum allowable slippage is determined within the transaction. This offers no slippage protection as the slippage is determined within the already manipulated pool.

Impact Details

Incorrect slippage would lead to swap manipulation by MEV/attacker

References

https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/platform/BelongCheckIn.sol?utm\\_source=immunefi#L664C9-L666C1

Proof of Concept

{% stepper %} {% step %}

Step

Attacker front-run: pushes pool so now 1 USDC => 0.90 LONG (price worsens for buyer). {% endstep %}

{% step %}

Step

Victim quotes at 0.90 and gets amountOutMinimum ≈ 0.90*(1−slippage). {% endstep %}

{% step %}

Step

Victim executes and receives ~0.90 LONG per USDC. {% endstep %}

{% step %}

Step

Attacker back-runs and profit = difference between what attacker got on the back-run and cost of front-run. {% endstep %} {% endstepper %}

The original report as published on Immunefi, by kodyvim. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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 derives the slippage-protected minimum output from a quote fetched in the same transaction, so the minimum reflects any manipulation already present in the pool rather than a pre-agreed safe value.

Impact

An attacker could manipulate the swap price and cause the victim to receive fewer tokens, leading to direct theft of user funds.

What the attacker needed

Attacker can front-run and back-run transactions; victim performs a swap through the contract

The fix

The contract should use a minimum output amount that is not derived from a same-transaction quote, such as a value supplied by the caller or a stored oracle price with a safety margin.

How it was found

  1. Attacker front-runs to push the pool price so 1 USDC buys only 0.90 LONG.
  2. Victim's transaction quotes at the worsened price and sets a minimum near 0.90 LONG per USDC.
  3. Victim's swap executes at about 0.90 LONG per USDC.
  4. Attacker back-runs and profits from the price difference.

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.

When you swap tokens on a decentralised exchange, you set a minimum amount you are willing to receive to protect against price changes. Here, the contract asks the exchange for a price and then immediately uses that same price as its minimum, so if an attacker moves the price just before the swap, the contract accepts the worse price. This lets the attacker profit at the victim's expense.

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 kodyvim

View all

3 more disclosed reports, best first.

More from Belong

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.