This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
chainNue - Adversary manipulate the middle path when calling execute_dca_order
, resulting user loss, benefiting the attacker
#182
Labels
Fix Submitted
Fix to the issue has been submitted
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
chainNue
high
Adversary manipulate the middle path when calling
execute_dca_order
, resulting user loss, benefiting the attackerSummary
Adversary manipulate the middle path when calling
execute_dca_order
, resulting user loss, benefiting the attackerVulnerability Detail
Allowing anyone to call the
execute_dca_order
function with a custom_uni_hop_path
introduce security issue. If an attacker constructs a malicious path with their own token in the middle, they could manipulate the liquidity and perform an exploit. The_uni_hop_path
parameter inexecute_dca_order
is really dangerous input which can be manipulated by attacker.For example a user want to Dca
USDC -> WETH
by postingpost_dca_order
with_token_in
is USDC, and_token_out
is WETH, and with themin_amount_out
generated from_calc_min_amount_out
which is based on twap and slippage percentage (in contrary,LimitOrders.vy
use inputmin_amount_out
for token out from thepost_limit_order
function, thus will not facing same effect like this issue)When attacker see this Dca order, they can create a new ERC20
MYTOKEN
(and will provide liquidity in uniswap) and plan to attack the Dca by selecting his own token as the middle path, soexecute_dca_order
will be executed usingUSDC -> MYTOKEN -> WETH
path.Since attacker can manipulate the liquidity of
MYTOKEN
in Uniswap, resulting user will get bad swap amount due to the custom path provided by attacker.Slippage and twap length as protection are not enough, because the middle token path is the problem here. Moreover, using twap with twap_length can also be manipulated by preparing / pre-attack pool since the
last_execution
andseconds_between_executions
is known, also the order's twap_length is visible, so attack scenario can prepared beforehand.Steps:
A malicious user creates a custom token called "MYTOKEN" and provides liquidity for it on Uniswap v3. They allocate liquidity to create extreme price ranges for MYTOKEN.
A regular user intends to swap USDC to WETH.
The malicious user intercepts the transaction and modifies the path by adding intermediate token with MYTOKEN. The new path becomes USDC -> MYTOKEN -> WETH.
Uniswap v3 receives the modified path and attempts to execute the swap based on the provided path.
Uniswap v3 calculates the best available price based on the modified path, which includes MYTOKEN.
Due to the manipulated liquidity pool of MYTOKEN, the price of MYTOKEN is significantly skewed, leading to an unfair price for the regular user executing the multi-hop swap.
The malicious user takes advantage of the distorted liquidity pool by executing multi-hop swaps involving MYTOKEN at highly advantageous prices.
Innocent users who unknowingly interact with the manipulated liquidity pool may receive unfavorable prices for their USDC to WETH swaps, leading to financial losses.
In this scenario, the malicious user modifies the path of the multi-hop swap by replacing the intended intermediate token with MYTOKEN. As a result, the malicious user exploits the manipulated liquidity pool and executes trades at favorable prices, while causing losses for other traders and disrupting the market equilibrium
Impact
User will get a bad rate (far from the normal rate) due to middle token rate is manipulated, thus losing his asset.
Code Snippet
https://github.com/sherlock-audit/2023-06-unstoppable/blob/main/unstoppable-dex-audit/contracts/spot-dex/Dca.vy#L163-L237
Tool used
Manual Review
Recommendation
Might need to have a minimal desired output amount of range (for the output token), or remove the option to input manual path with anyone can call the
execute_dca_order
then replace it with the Oracle price rate. Other way, consider implement a whitelist token for swap path.The text was updated successfully, but these errors were encountered: