DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: high
Invalid

Malicious path manipulation leads to cashing out of funds

Summary

In the claimAndSwap and _swapUnderlyingToAsset functions of the StrategyArb contract, an attacker can set a malicious exchange path by manipulating the _path parameter, thereby bypassing the check conditions in the exchange process and ultimately making illegal profits. Specifically, an attacker can set a malicious exchange path so that the amount of assets after exchange meets the conditions checked by the contract, thereby making profits through an unreasonable exchange ratio (for example, 1:1.2).

This risk also exists in the StrategyOp contract.

Vulnerability Details

https://github.com/Cyfrin/2024-12-alchemix/blob/main/src/StrategyArb.sol#L71

In the claimAndSwap function, the contract extracts the specified amount of WETH through the transmuter.claim function and converts WETH to alETH through the specified exchange path. The contract ensures that no loss occurs during the exchange process by checking the balance change after the exchange (balAfter - balBefore >= _minOut) and the minimum receiving amount _minOut. However, an attacker can manipulate the _path parameter, forge the exchange path, and use a relatively large exchange ratio (such as 100:120) to transfer part of the alETH to his own wallet.
Specifically:
Suppose the exchange ratio of WETH and alETH is 100:120. That is, 100 WETH is exchanged for 120 alETH, but the StrategyArb contract only requires the exchange amount to be greater than the input 100, that is, although 100 WETH is exchanged for 120 alETH, as long as 101 alETH is sent to the StrategyArb contract, the contract's judgment can be satisfied. Since the _path parameter is controllable, the _path can be set to WETH --> AttackToken --> alETH. The exchange ratio of these two trading pairs is 100 WETH --> 120 AttackToken, 120 AttackToken --> 120 alETH. At this time, the attacker uses 100 WETH --> 120 AttackToken, and then 101 AttackToken --> 101 alETH. And 101 alETH is sent to the StrategyArb contract to successfully complete the exchange. In this transaction, the attacker has made a profit of 19 alETH. The larger the exchange of WETH and alETH, the more profit the attacker will make.

Impact

This vulnerability allows an attacker to illegally extract funds from the contract by constructing a malicious exchange path, bypassing the price and balance checking mechanism of the contract. The attacker may obtain more alETH than normal through the exchange operation, thereby obtaining improper benefits. This vulnerability poses a serious threat to the financial security and stability of the contract.

Tools Used

Manual analysis

Recommendations

Path verification, strictly verify the _path parameter to ensure that the path can only be exchanged from WETH to alETH, and prohibit transfer through malicious tokens. Limit the path length, limit the length of the exchange path, and prevent complex multi-step paths from being used to manipulate the exchange process.

Updates

Appeal created

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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