This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
carrotsmuggler - Price calculation susceptible to flashloan exploits #451
Labels
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
Comments
github-actions
bot
added
High
A valid High severity issue
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
labels
Jun 5, 2023
This was referenced Jun 5, 2023
Closed
smiling_heretic - Direct transfer of USSD or DAI to the
uniPool
causes rebalance
to malfunction
#747
Closed
This was referenced Jun 5, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
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
carrotsmuggler
high
Price calculation susceptible to flashloan exploits
Summary
Contract uses uniswap
slot0
price instead of TWAP price.slot0
price can be manipulated with flash loans.Vulnerability Detail
The contract uses the uniswap DAI-USSD pool to get the price of USSD. It however uses the instantaneous price from
slot0
instead of the TWAP price. Theslot0
price is calculated from the ratios of the assets. This ratio can however be manipulated by buying/selling assets in the pool.https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/USSDRebalancer.sol#L71-L80
Thus any user can take a flashloan, use those funds to manipulate the price of USSD, and then trigger a rebalance. The attacks can be made profitable by providing just-in-time liquidity to the various pools that
reabalance
interacts with, draining the contract of collateral through arbitrage.Impact
Price can be manipulated and
rebalance
can be called any time. Susceptible to flash loan exploits.Code Snippet
https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/USSDRebalancer.sol#L71-L80
Tool used
Manual Review
Recommendation
Use TWAP price instead of
slot0
price. Here is an example implementation of TWAP.The text was updated successfully, but these errors were encountered: