Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Incorrect Handling of Collateral Asset Approval in rebalanceVaultsAssets Function

Summary

The rebalanceVaultsAssets function is vulnerable to Incorrect Handling of Collateral Asset Approval, which could allow a malicious or compromised DEX adapter to exploit remaining token approvals and steal funds from the vault. This vulnerability arises because the function approves the collateral asset to the DEX adapter for the swap operation but fails to reset the approval to zero after the swap is completed.

Also this issue is available in the _convertAssetsToUsdc function where the approval is not set to zero.

Vulnerability Details

The function approves the collateral asset to the DEX adapter using the approve function but does not reset the approval to zero after the swap is completed. This leaves the vault vulnerable to unauthorized transfers if the DEX adapter is malicious or compromised.

// approve the collateral token to the dex adapter and swap assets for USDC
IERC20(ctx.inDebtVaultCollateralAsset).approve(ctx.dexAdapter, assetInputNative);
dexSwapStrategy.executeSwapExactInputSingle(swapCallData);
@> audit The approval is not reset to zero

Exploitation Scenarios

  • An attacker deploys a malicious DEX adapter that exploits the remaining approval to steal funds.

  • The malicious adapter transfers additional tokens from the vault after the swap is completed.

Impact

  • An attacker could steal funds from the vault by exploiting the remaining approval.

Tools Used

Manual Code Review

Recommendations

  • Reset the approval to zero after the swap is completed to prevent unauthorized transfers.

IERC20(ctx.inDebtVaultCollateralAsset).approve(ctx.dexAdapter, 0);
  • Use the safeApprove function from OpenZeppelin's SafeERC20 library to handle approvals safely.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.