Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

carrotsmuggler - Price calculation susceptible to flashloan exploits #451

Open
sherlock-admin opened this issue May 23, 2023 · 0 comments
Open
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

@sherlock-admin
Copy link
Contributor

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. The slot0 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.

@github-actions 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
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
Projects
None yet
Development

No branches or pull requests

1 participant