Skip to content
Business logic Audit finding Intermediate

Permanent freeze of user token due to unhandled partial fill refunds for swap via 1inch in dexaggregatorwrapperwithpredicateproxy

The proxy contract that wraps 1inch swaps does not handle the refund of unused source tokens when the partial-fill flag is set. A user who swaps with that flag can have the unspent tokens sent to the proxy, which has no way to return or unwrap them, so those funds are permanently frozen.

perseverance Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

51283 sc critical permanent freeze of user token due to unhandled partial fill refunds for swap via 1inch in dexaggregatorwrapperwithpredicateproxy

Submitted on Aug 1st 2025 at 12:08:18 UTC by @perseverance for Attackathon | Plume Network

Description

Short summary

The DexAggregatorWrapperWithPredicateProxy.sol contract is vulnerable to a permanent freeze of user funds when interacting with the 1inch DEX aggregator. If a user initiates a swap using the depositOneInch or depositAndBridgeOneInch function and includes the _PARTIAL_FILL flag in the swap parameters, any unspent token refunded by 1inch is sent back to the proxy contract. The proxy contract has no mechanism to withdraw, unwrap, or transfer this returned token, causing the user's funds to be permanently and irreversibly locked within the contract.

The vulnerability

The core issue is that depositOneInch / depositAndBridgeOneInch do not account for 1inch's partial-fill refund behavior. When _PARTIAL_FILL is set in AggregationRouterV6.SwapDescription, the 1inch router refunds unused source tokens to msg.sender. In this integration, msg.sender is the proxy contract. The proxy:

  • receives the refunded ERC20 (e.g., WETH),
  • has no function to unwrap WETH to ETH,
  • has no generic sweep/transfer for arbitrary ERC20 tokens,
  • does not forward the refunded token back to the user.

Consequently, refunded tokens remain trapped in the proxy contract permanently.

Relevant contract locations:

Vulnerable excerpt from depositOneInch:

Solidity
function depositOneInch(
        ERC20 supportedAsset,
        TellerWithMultiAssetSupport teller,
        uint256 minimumMint,
        address executor,
        AggregationRouterV6.SwapDescription calldata desc,
        bytes calldata data,
        uint256 nativeValueToWrap,
        PredicateMessage calldata predicateMessage
    )
        external
        payable  
        nonReentrant
        returns (uint256 shares)
    {
        _checkPredicateProxy(predicateMessage);
        uint256 supportedAssetAmount =
            _oneInchHelper(supportedAsset, address(teller), executor, desc, data, nativeValueToWrap); // @audit call _oneInchHelper
    
    } 

Vulnerable excerpt from _oneInchHelper:

Solidity
function _oneInchHelper(
        ERC20 supportedAsset,
        address teller,
        address executor,
        AggregationRouterV6.SwapDescription calldata desc,
        bytes calldata data,
        uint256 nativeValueToWrap
    )
{

    if (useNative) {
            // Ensure desc.srcToken matches canonicalWrapToken address
            if (address(desc.srcToken) != address(canonicalWrapToken) || desc.amount != nativeValueToWrap) {
                revert DexAggregatorWrapper__InvalidSwapDescription();
            }
            // Use standard approve (as requested) - potential risk if WETH impl changes non-standardly
            canonicalWrapToken.approve(address(aggregator), nativeValueToWrap); // @audit approve token to aggregator to transferFrom the proxy contract 
        } else {
            ERC20 depositAsset = desc.srcToken; // Assumes desc.srcToken is ERC20 type
            uint256 depositAmount = desc.amount;

            // Use safeTransferFrom
            depositAsset.safeTransferFrom(msg.sender, address(this), depositAmount);

            // Approve agregator to take tokens from this contract
            depositAsset.safeApprove(address(aggregator), depositAmount); // @audit approve token to aggregator to transferFrom the proxy contract 
        }

        // Perform swap
        (supportedAssetAmount,) = aggregator.swap(executor, desc, data); // @audit-issue Call OneInch Aggregator to swap. But not handle the refund token in case _PARTIAL_FILL is used 

}

1inch refund logic (relevant excerpt from AggregationRouterV6):

Solidity
function swap(
    IAggregationExecutor executor,
    SwapDescription calldata desc,
    bytes calldata data
)
    external
    payable
    whenNotPaused()
    returns (
        uint256 returnAmount,
        uint256 spentAmount
    )
{
    // ... 
    
    returnAmount = _execute(executor, msg.sender, desc.amount, data); // @audit perform swap 
    spentAmount = desc.amount;
    // When _PARTIAL_FILL is enabled, unused srcToken is sent back to msg.sender
    if (desc.flags & _PARTIAL_FILL != 0) {
        uint256 unspentAmount = srcToken.uniBalanceOf(address(this));
        if (desc.flags & _PARTIAL_FILL != 0) {
                uint256 unspentAmount = srcToken.uniBalanceOf(address(this));
                if (unspentAmount > 1) {
                    // we leave 1 wei on the router for gas optimisations reasons
                    unchecked { unspentAmount--; }
                    spentAmount -= unspentAmount;
                    srcToken.uniTransfer(payable(msg.sender), unspentAmount); // @audit-issue 'msg.sender' is the Proxy contract . So the token is refunded to the DexAggregatorWrapperWithPredicateProxy contract 
                }
                if (returnAmount * desc.amount < desc.minReturnAmount * spentAmount) revert RouterErrors.ReturnAmountIsNotEnough(returnAmount, desc.minReturnAmount * spentAmount / desc.amount);
            } 
        else {
                if (returnAmount < desc.minReturnAmount) revert RouterErrors.ReturnAmountIsNotEnough(returnAmount, desc.minReturnAmount);
            }
    }
    // ...
}

Because the router refunds the unused srcToken to msg.sender (the proxy contract), any unspent WETH / depositAsset is transferred to the proxy and becomes irrecoverable given the proxy's missing recovery/unwrapping logic.

Severity assessment

{% hint style="danger" %} Bug Severity: Critical

Impact: Permanent freezing of funds. The refunded tokens (e.g., WETH) become permanently trapped in the proxy contract with no recovery mechanism. {% endhint %}

Suggested remediation

{% hint style="warning" %} The function should detect and forward any refunded source token (including WETH) back to the user (or otherwise provide a recovery path). Possible mitigations include:

  • After the aggregator.swap(...) call, check the proxy contract's balance of the source token and transfer any excess back to the user.
  • Provide a controlled admin or user-facing sweep/withdraw function for arbitrary ERC20s (with appropriate access controls and safety checks).
  • If WETH is used, provide an unwrap flow to convert any returned WETH to ETH and refund to the user.
  • Disallow _PARTIAL_FILL flag in desc.flags when calling 1inch from the proxy if proper handling is not implemented. {% endhint %}

Proof of Concept (Conceptual)

This scenario demonstrates the permanent loss of funds.

{% stepper %} {% step %}

Step

User's Action: A user ("Victim") wants to swap 10 ETH for USDC, but is willing to accept a partial fill. They call depositOneInch with desc including the _PARTIAL_FILL flag and send msg.value = 10 ether. {% endstep %}

{% step %}

Step

Proxy's Action: The DexAggregatorWrapperWithPredicateProxy receives 10 ETH, wraps it into 10 WETH (if using native flow), and calls the 1inch aggregator swap. {% endstep %}

{% step %}

Step

1inch Action: The 1inch aggregator partially fills 7 WETH -> USDC and, because _PARTIAL_FILL is set, refunds the remaining 3 WETH to msg.sender (the proxy contract). {% endstep %}

{% step %}

Step

Consequence: The proxy contract now holds 3 WETH. The proxy has no function to unwrap or transfer this WETH back to the user or elsewhere. The 3 WETH is permanently trapped. {% endstep %}

{% step %}

Step

Result: The user receives shares corresponding to the 7 WETH swap, but the 3 WETH is permanently lost. {% endstep %} {% endstepper %}

Sequence diagram (mermaid):

MERMAID
sequenceDiagram
    participant User
    participant Proxy as "DexAggregatorWrapperWithPredicateProxy"
    participant WETH_Contract as "WETH Contract"
    participant OneInch_Aggregator as "1inch Aggretator"

    %% --- Step 1: User initiates a swap with Partial Fill enabled ---
    User->>Proxy: depositOneInch(desc with _PARTIAL_FILL) | msg.value: 10 ETH
    Proxy->>WETH_Contract: deposit{value: 10 ETH}()
    WETH_Contract-->>Proxy: Mints 10 WETH
    
    %% --- Step 2: Proxy calls 1inch, which performs a partial swap ---
    Proxy->>OneInch_Aggregator: swap(10 WETH, ...)
    note over OneInch_Aggregator: Order is only partially filled. <br/> Swaps 7 WETH, 3 WETH remains.
    
    %% --- Step 3: 1inch refunds unused WETH to the Proxy, where it gets stuck ---
    OneInch_Aggregator->>Proxy: transfer(3 WETH)
    note right of Proxy: Proxy receives 3 WETH. <br/> It has no function to move or unwrap it. <br/> The 3 WETH is now permanently frozen.

    %% --- Final outcome for the user ---
    Proxy-->>User: returns shares for the 7 WETH swap
    note over User, Proxy: User has permanently lost the 3 WETH.

References

(End of report)

The original report as published on Immunefi, by perseverance. 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 proxy calls the 1inch router without checking or forwarding any source-token refund, and it has no sweep or unwrap function, so partial-fill refunds sent to it are trapped.

Impact

The unspent source tokens from a partial fill are permanently frozen in the proxy contract, and the user loses that portion of their funds.

What the attacker needed

User calls depositOneInch or depositAndBridgeOneInch; partial-fill flag is set in the swap description; the 1inch order is only partially filled

The fix

The proxy should forward any refunded source token back to the user, or provide a controlled sweep or unwrap function, or reject the partial-fill flag.

How it was found

  1. The user calls depositOneInch with the partial-fill flag set and sends native ETH.
  2. The proxy wraps the ETH into WETH and approves the 1inch router.
  3. The 1inch router partially fills the swap and refunds the unused WETH to the proxy.
  4. The proxy holds the refunded WETH but has no function to unwrap or transfer it, so it stays frozen.

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 user swaps tokens through a helper contract that forwards the request to a large exchange router. If the router can only fill part of the order, it sends the leftover tokens back to whoever asked for the swap, which here is the helper contract. That helper has no function to send those leftovers onward, so the tokens stay stuck there forever.

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 perseverance

View all

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