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
Anyone can execute a pending DCA order by calling Dca.execute_dca_order(). The caller provides the path and Uniswap fees to determine which UniV3 pools the tokens are exchanged from/to.
This open approach can allow an attacker to steal all value from a DCA order. The attacker will perform the following steps:
Create their own ERC20 ($STEAL)
Deploy multiple STEAL/token pools
Provide minimal liquidity to these pools
Execute Unstoppable DCA orders and route them through these pools
Since Dca._calc_min_amount_out() relies on the pool's TWAP value for the min_amount_out and the TWAP value of the pool is controlled by the attacker, the attacker can make this nearly 0.
Vulnerability Detail
An attacker can execute a DCA order with an arbitrary 3-token path: WETH -> STEAL -> USDC
Therefore, an attacker will create both STEAL/WETH and STEAL/USDC pools with whichever fee amount desired. It really doesn't matter because only the attacker owns STEAL. These pools will contain unfavorable exchange rates between the tokens.
The pool's TWAP values will be low (nearly 0), which the call to Dca._calc_min_amount_out() will read as the truth.
The twap_value is calculated by calling TWAP.getTwap() which reads the observations from the pool. The returned TWAP value is completely controlled by the attacker who is the only account that owns STEAL and can provide liquidity. Also, STEAL would also have logic in its _transfer() that only allows it to be transferred to specific places to ensure that full TWAP control can be achieved.
Contain a whitelist of approved path/fee combinations. As long as arbitrary 3-token paths are allowed, anyone can route these orders through pools with arbitrary TWAP values.
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
0xDjango
high
DCA order value can be stolen in entirety
Summary
Anyone can execute a pending DCA order by calling
Dca.execute_dca_order()
. The caller provides the path and Uniswap fees to determine which UniV3 pools the tokens are exchanged from/to.This open approach can allow an attacker to steal all value from a DCA order. The attacker will perform the following steps:
Since
Dca._calc_min_amount_out()
relies on the pool's TWAP value for themin_amount_out
and the TWAP value of the pool is controlled by the attacker, the attacker can make this nearly 0.Vulnerability Detail
An attacker can execute a DCA order with an arbitrary 3-token path:
WETH -> STEAL -> USDC
Therefore, an attacker will create both
STEAL/WETH
andSTEAL/USDC
pools with whichever fee amount desired. It really doesn't matter because only the attacker owns STEAL. These pools will contain unfavorable exchange rates between the tokens.The pool's TWAP values will be low (nearly 0), which the call to
Dca._calc_min_amount_out()
will read as the truth.The
twap_value
is calculated by callingTWAP.getTwap()
which reads the observations from the pool. The returned TWAP value is completely controlled by the attacker who is the only account that owns STEAL and can provide liquidity. Also, STEAL would also have logic in its_transfer()
that only allows it to be transferred to specific places to ensure that full TWAP control can be achieved.Impact
Code Snippet
https://github.com/sherlock-audit/2023-06-unstoppable/blob/main/unstoppable-dex-audit/contracts/spot-dex/Dca.vy#L268-L274
Tool used
Manual Review
Recommendation
Contain a whitelist of approved path/fee combinations. As long as arbitrary 3-token paths are allowed, anyone can route these orders through pools with arbitrary TWAP values.
Duplicate of #182
The text was updated successfully, but these errors were encountered: