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 Nov 26, 2023. It is now read-only.
sherlock-admin opened this issue
May 23, 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
The getOwnValuation uses the spotprice of the uniswap token and not the twap price.
Vulnerability Detail
The getOwnValuation gets the price of USSD according to the price of the USSD/DAI pool. However it uses the spotprice like this:
(uint160sqrtPriceX96,,,,,,) = uniPool.slot0();
It does some more calculations to get the price as USSD/DAI.
The getOwnValuation function is called in rebalance and SellUSSDBuyCollateral. Depending on the output rebalance will either buy or sell USSD.
This makes it possible for anyone to flashloan and influence the output of getOwnValuation and call rebalance. The protocol will now buy or sell USSD when it's not warranted, bringing it in a unstable state and making it even possible for the attacker to profit.
The attack would happen like this:
attacker deposits dai and gets ussd via mintForToken
attacker flashloans a sufficient amount of dai to destabilize the pool
Call rebalance
Protocol will call BuyUSSDSellCollateral because getOwnValuation uses spot price. Ussd is < 1e6, since there's more ussd than dai in the pool.
Protocol will sell dai and buy ussd to bring the pool in balance
Repay the flashloan, the pool now has a lot more dai than ussd, so 1 ussd will be worth more than 1 dai
Sell the ussd into the pool for profit and receive more than the unit price that was paid for in the deposit
Impact
Anyone can make the protocol buy or sell USSD by executing a flashloan and make profit of it by selling the received ussd for more than it's worth.
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
0xHati
high
getOwnValuation uses spot price and not the twap
Summary
The
getOwnValuation
uses the spotprice of the uniswap token and not the twap price.Vulnerability Detail
The
getOwnValuation
gets the price of USSD according to the price of the USSD/DAI pool. However it uses the spotprice like this:It does some more calculations to get the price as USSD/DAI.
The
getOwnValuation
function is called inrebalance
andSellUSSDBuyCollateral
. Depending on the output rebalance will either buy or sell USSD.This makes it possible for anyone to flashloan and influence the output of
getOwnValuation
and call rebalance. The protocol will now buy or sell USSD when it's not warranted, bringing it in a unstable state and making it even possible for the attacker to profit.The attack would happen like this:
mintForToken
BuyUSSDSellCollateral
becausegetOwnValuation
uses spot price. Ussd is < 1e6, since there's more ussd than dai in the pool.Impact
Anyone can make the protocol buy or sell
USSD
by executing a flashloan and make profit of it by selling the received ussd for more than it's worth.Code Snippet
Link to code
Tool used
Manual Review
Recommendation
Use the TWAP price and don't use spot price as it's easy to manipulate.
Medium article explaining in detail
Duplicate of #451
The text was updated successfully, but these errors were encountered: