You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
sherlock-admin opened this issue
Jul 5, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
�Dca.vy: Stealing User Funds Provided for DCA by Creating a New Pool and Manipulating Price
Summary
In execute_dca_order function of Dca.vy contract which allows users to exploit DCA trades by creating custom tokens, manipulating pool prices, and consequently, draining user funds.
Vulnerability Detail
The execute_dca_order function enables the execution of DCA trades. It uses the Uniswap pool's TWAP price calculated by the _calc_min_amount_out function to ensure that trades are conducted at an appropriate price.
Users can specify a trading path of up to three lengths. An attacker can exploit this by creating custom tokens, manipulating pool prices, and consequently draining funds intended for DCA trades.
The _calc_min_amount_out function serves as a sort of slippage control, but since users can define the trade path, an attacker can set this value to 0 and drain user funds. If the result of getTwap is 0, _calc_min_amount_out is calculated as 0.
The vulnerability occurs when getSqrtTwapX96 from Univ3Twap.sol returns a value so large that it results in zero for the TWAP. This behavior can be observed on the Arbitrum mainnet.
An exploitation scenario could look like this:
User A places a DCA order to buy a certain amount of WBTC with USDT every day.
The attacker deploys token B, creates a USDT-token B pair, and sets the value of token B to be extremely high.
The attacker creates a token B-WBTC pool and sets the value of token B to be extremely low.
The attacker executes the DCA order with the path set to [USDT, token B, WBTC].
min_amount_out is set to 0, and User A receives almost no WBTC.
The attacker withdraws from the LP, draining User A's funds.
Impact
The exploit can lead to substantial financial loss for users who engage in DCA trades as they could lose their funds to attackers who manipulate token prices.
To prevent such exploitation, it is recommended to adopt an external price feed, such as Chainlink oracle, when calculating min_amount_out. This ensures that the trades are based on accurate and trusted price data that is less susceptible to manipulation.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
pengun
high
�Dca.vy: Stealing User Funds Provided for DCA by Creating a New Pool and Manipulating Price
Summary
In
execute_dca_order
function ofDca.vy
contract which allows users to exploit DCA trades by creating custom tokens, manipulating pool prices, and consequently, draining user funds.Vulnerability Detail
The
execute_dca_order
function enables the execution of DCA trades. It uses the Uniswap pool's TWAP price calculated by the_calc_min_amount_out
function to ensure that trades are conducted at an appropriate price.Users can specify a trading path of up to three lengths. An attacker can exploit this by creating custom tokens, manipulating pool prices, and consequently draining funds intended for DCA trades.
The
_calc_min_amount_out
function serves as a sort of slippage control, but since users can define the trade path, an attacker can set this value to 0 and drain user funds. If the result ofgetTwap
is 0,_calc_min_amount_out
is calculated as 0.The vulnerability occurs when getSqrtTwapX96 from Univ3Twap.sol returns a value so large that it results in zero for the TWAP. This behavior can be observed on the Arbitrum mainnet.
An exploitation scenario could look like this:
USDT-token B
pair, and sets the value of token B to be extremely high.token B-WBTC
pool and sets the value of token B to be extremely low.Impact
The exploit can lead to substantial financial loss for users who engage in DCA trades as they could lose their funds to attackers who manipulate token prices.
Code Snippet
https://github.com/sherlock-audit/2023-06-unstoppable/blob/main/unstoppable-dex-audit/contracts/spot-dex/Dca.vy#L268
https://github.com/sherlock-audit/2023-06-unstoppable/blob/main/unstoppable-dex-audit/contracts/utils/Univ3Twap.sol#L55
https://github.com/sherlock-audit/2023-06-unstoppable/blob/main/unstoppable-dex-audit/contracts/utils/Univ3Twap.sol#L41-L49
Tool used
Manual Review
Recommendation
To prevent such exploitation, it is recommended to adopt an external price feed, such as Chainlink oracle, when calculating
min_amount_out
. This ensures that the trades are based on accurate and trusted price data that is less susceptible to manipulation.Duplicate of #182
The text was updated successfully, but these errors were encountered: