Skip to content
Business logic Audit finding Intermediate

Dex aggregator partial fill token loss

The contract transfers the full user-supplied token amount into itself and approves a DEX aggregator, but if the aggregator only partially fills the swap, the leftover tokens stay in the contract and are never refunded. A user who enables partial fill can therefore permanently lose the unused portion of their deposit.

Blobism Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

49854 sc critical dex aggregator partial fill token loss

Submitted on Jul 20th 2025 at 00:39:49 UTC by @Blobism for Attackathon | Plume Network

Description

If one of the deposit methods is invoked with partial fill enabled in the DEX swap, some of the user's sent tokens can be left in the contract, and the contract does not attempt to refund them.

Brief/Intro

DEX aggregators such as 1inch AggregationRouterV6 allow for partial fill, where only some of the provided ERC20 tokens are used in the swap. If a user invokes one of the deposit or "deposit and bridge" methods with partial fill enabled, the contract will not attempt to return any leftover tokens to the user, effectively locking them in the contract.

Vulnerability Details

DEX aggregators (e.g., 1inch AggregationRouterV6) support partial fills. The vulnerable flow transfers the full user-provided ERC20 amount into the contract, approves the aggregator, then calls the aggregator swap. If the swap partially fills, leftover tokens remain in the contract and are not refunded.

Example excerpt showing the problematic flow:

Solidity
if (useNative) {
    // ...
} else {
    ERC20 depositAsset = desc.srcToken; // Assumes desc.srcToken is ERC20 type
    uint256 depositAmount = desc.amount;

    // Use safeTransferFrom
    depositAsset.safeTransferFrom(msg.sender, address(this), depositAmount);
    // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    // all user funds moved to contract
    // (the issue lies in the fact that leftovers are not returned)

    // Approve agregator to take tokens from this contract
    depositAsset.safeApprove(address(aggregator), depositAmount);
}

// Perform swap
(supportedAssetAmount,) = aggregator.swap(executor, desc, data);

Recommended fix: either refund any remaining ERC20 tokens after the swap, or enforce no partial fill (disallow partial fills via aggregator parameters).

Impact Details

Users who make use of partial fill with any available DEX are vulnerable to permanently losing their tokens to the contract.

References

Note: OKX router may have similar options, but the reporter did not investigate. More details on OKX can be provided if needed.

Proof of Concept

{% stepper %} {% step %}

Trigger deposit with partial fill enabled

User calls depositOneInch or depositAndBridgeOneInch with partial fill flag set in AggregationRouterV6.SwapDescription. {% endstep %}

{% step %}

Partial fill occurs

The aggregator performs a partial swap and does not consume the full provided token amount. {% endstep %}

{% step %}

Leftover tokens locked

Remaining tokens are left in the contract because the contract does not refund them, effectively locking the funds. {% endstep %} {% endstepper %}

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

The deposit flow moves the entire user amount into the contract and approves the aggregator, but never refunds any tokens left over after a partial fill.

Impact

Users who enable partial fill with a supported DEX could permanently lose the unused tokens to the contract.

What the attacker needed

User enables partial fill in the swap; aggregator supports partial fills

The fix

The contract should refund any remaining ERC20 tokens after the swap, or disallow partial fills through the aggregator parameters.

How it was found

  1. The user calls a deposit or deposit-and-bridge method with partial fill enabled in the swap description.
  2. The aggregator performs a partial swap and does not consume the full token amount.
  3. The remaining tokens stay in the contract because no refund is made, locking the funds.

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 DEX aggregator is a service that finds swap routes across exchanges. Some aggregators let a swap fill only part of the requested amount, leaving some tokens unused. Here the contract pulls all of the user's tokens first and never sends back the unused part, so those tokens are stuck in the contract.

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 Blobism

View all

19 more disclosed reports, best first.

More from Plume Network

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.