Uncleaned partial approval consumption in dex aggregator integration leads to permanent dos
The contract approves tokens to DEX aggregators but never resets the allowance after a swap, so if an aggregator consumes only part of the approved amount, a non-zero allowance remains. Because safeApprove reverts when changing a non-zero allowance to another non-zero value, all future swaps of that token fail permanently.
- Disclosed after under an hour
53011 sc critical uncleaned partial approval consumption in dex aggregator integration leads to permanent dos
Submitted on Aug 14th 2025 at 16:38:29 UTC by @vivekd for Attackathon | Plume Network
- Report ID: #53011
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/attackathon-plume-network-nucleus-boring-vault/blob/main/src/helper/DexAggregatorWrapperWithPredicateProxy.sol
- Impacts:
- Smart contract unable to operate due to lack of token funds
Description
Brief/Intro
The DexAggregatorWrapperWithPredicateProxy contract fails to clean up token approvals after DEX swaps, creating a critical vulnerability when aggregators consume less than the approved amount.
Since 1inch and OKX aggregators support partial fills as a documented feature, lingering approvals will cause safeApprove to revert on all subsequent transactions for affected tokens, permanently disabling the contract.
Vulnerability Details
The vulnerability exists in the approval pattern used in both _oneInchHelper and _okxHelper functions.
When the contract approves tokens for swapping, it does not verify that the full approved amount was consumed, nor does it reset approvals to zero after the swap.
Vulnerable Code in _oneInchHelper (lines 267-271):
{% code title="DexAggregatorWrapperWithPredicateProxy.sol (excerpt)" %}
// Approve aggregator for full amount
depositAsset.safeApprove(address(aggregator), depositAmount);
// Perform swap - ignores spentAmount return value!
(supportedAssetAmount,) = aggregator.swap(executor, desc, data);
// No cleanup of remaining approval
{% endcode %}
Vulnerable Code in _okxHelper (lines 321-333):
{% code title="DexAggregatorWrapperWithPredicateProxy.sol (excerpt)" %}
// Approve OKX for full amount
depositAsset.safeApprove(okxApprover, fromTokenAmount);
// Execute swap
(bool success, bytes memory result) = address(okxRouter).call(okxCallData);
// No verification of actual consumption or cleanup
{% endcode %}
The 1inch AggregationRouterV6 explicitly supports partial fills through the _PARTIAL_FILL flag, returning a spentAmount that can be less than the approved amount. This is a documented feature for handling low liquidity scenarios.
When a swap consumes only 80% of the approved tokens (common during slippage optimization), 20% approval remains active.
The critical issue arises because SafeERC20.safeApprove() reverts when attempting to change a non-zero approval to another non-zero value:
// Next user attempting to swap the same token
depositAsset.safeApprove(address(aggregator), newAmount); // REVERTS!
// Error: "SafeERC20: approve from non-zero to non-zero allowance"
Impact Details
- Once triggered, the contract becomes permanently unusable for affected tokens.
- All users attempting to swap the same token will have transactions revert.
- No recovery mechanism exists — the contract lacks owner functions to reset approvals.
- Can be triggered accidentally through normal usage or deliberately by an attacker.
{% hint style="danger" %} Severity: Critical — leads to permanent DoS for affected tokens. {% endhint %}
Proof of Concept
{% stepper %} {% step %}
Initial State
- DexAggregatorWrapperWithPredicateProxy is deployed
- Users are swapping tokens normally through the wrapper {% endstep %}
{% step %}
Trigger Partial Consumption
- User A initiates swap of 1000 USDC for ETH via 1inch
- Contract approves 1000 USDC to aggregator (line 267)
- 1inch aggregator encounters slippage/optimization and only consumes 800 USDC
- Swap completes successfully, but 200 USDC approval remains {% endstep %}
{% step %}
DoS Triggered
- User B attempts to swap USDC for any token
- Contract calls
depositAsset.safeApprove(aggregator, amount)(line 267) - Transaction reverts with "SafeERC20: approve from non-zero to non-zero allowance"
- All subsequent USDC swaps fail permanently {% endstep %} {% endstepper %}
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 contract approves the full amount to the aggregator but does not reset the approval to zero after the swap, and safeApprove reverts when changing a non-zero allowance to another non-zero value.
Impact
Once a partial fill leaves a non-zero allowance, the contract becomes permanently unusable for that token because every subsequent swap reverts and there is no owner function to reset approvals.
What the attacker needed
Aggregator performs a partial fill; no owner function to reset approvals
The fix
The contract should reset the token approval to zero after each swap, or use a safe allowance pattern that handles existing non-zero allowances.
How it was found
- The wrapper contract is deployed and users swap tokens normally.
- User A swaps 1000 USDC for ETH via 1inch; the contract approves 1000 USDC to the aggregator.
- The aggregator consumes only 800 USDC, leaving 200 USDC approval active.
- User B tries to swap USDC; the contract calls safeApprove with a new amount.
- The transaction reverts because the allowance is non-zero, and all later USDC swaps fail.
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 smart contract lets a swapping service spend its tokens by giving it an allowance. If the service only uses part of that allowance, the leftover permission stays. The contract then cannot give a new allowance because the token library refuses to change a non-zero allowance directly to another non-zero value, so every later swap of that token fails.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.