AMM pool can be drained using a flashloan and calling stabilize
#372
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
stonesandtrees
Vulnerability details
Impact
All of the
rewardToken
in a given AMM pool can be removed from the AMM pool and distributed as LP rewards.Proof of Concept
In the
stabilize
method in theStabilizerNode
the initial check to see if the Malt price needs to be stabilized it uses a short period TWAP:https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/StabilizerNode.sol#L156
However, if the price is above the threshold for stabilization then the trade size required to stabilize looks at the AMM pool directly which is vulnerable to flashloan manipulation.
https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/DexHandlers/UniswapHandler.sol#L250-L275
Attack:
stabilize
. This will pass the TWAP check and execute_distributeSupply
which in turn ultimately calls_calculateTradeSize
in theUniswapHandler
. This calculation will determine that almost all of therewardToken
needs to be removed from the pool to return the price to peg.rewardToken
from the pool.rewardToken
as rewards. 0.3% of which goes directly to the attacker and the rest goes to LP rewards, swing trader and the treasury.The amount of money that can be directly stolen by a malicious actor is small but it can cause a lot of pain for the protocol as the pool will be destroyed and confusion around rewards will be created.
Tools Used
Manual review
Recommended Mitigation Steps
Use a short TWAP to calculate the trade size instead of reading directly from the pool.
The text was updated successfully, but these errors were encountered: