51352 sc critical user will lose the unspent amount when executing partial swaps via 1inch
Description
Brief/Intro
Vulnerability Details
struct SwapDescription { ERC20 srcToken; ERC20 dstToken; address payable srcReceiver; address payable dstReceiver; uint256 amount; uint256 minReturnAmount; @> uint256 flags; } function swap( IAggregationExecutor executor, @> SwapDescription calldata desc, bytes calldata data ) external payable whenNotPaused() returns ( uint256 returnAmount, uint256 spentAmount ) { ... // @audit-issue returning the spent amount to `msg.sender` @> 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); } ... }function _oneInchHelper( ERC20 supportedAsset, address teller, address executor, AggregationRouterV6.SwapDescription calldata desc, bytes calldata data, uint256 nativeValueToWrap ) internal returns (uint256 supportedAssetAmount) { .... // Perform swap @> (supportedAssetAmount,) = aggregator.swap(executor, desc, data); ... return supportedAssetAmount; }
Impact Details
Recommendation
Proof of Concept
Result
Previous52974 sc medium when the approval to the okxapprover is not fully spent the deposit function will be blockedNext51083 sc insight claimall only loops over active reward tokens and ignores historical tokens
Was this helpful?