Minimum slippage allowed in BaseAdapter is MIN_SLIPPAGE_BPS=100
which is high for the Curve stable swaps where usual slippage tolerance equals to 0.1%
. This allows attacker to frontrun swap function in the protocol, manipulate the Curve pool balance, and profit from the swaps, while protocol will take less tokens than he should.
Minimum slippage allowed is set to 100
in Constants.sol:34:
Contract calculates minimum amount out depending on Chainlink price and slippageToleranceBps
which can be >=MIN_SLIPPAGE_BPS
:
And because 1% is high slippage for Curve stable swaps, attacker can manipulate price in Curve pool just before protocol will call swap and attacker will take profit while protocol will lose 1% on swap.
Take for example that protocol wants to do CreditDelegationBranch.sol:rebalanceVaultsAssets() (attacker can easily frontrun this function call because it's called by ChainlinkKeeper when checkUpkeep()
returns true
).
Pre-conditions:
Keeper wants to do rebalance for in-credit vault by assets in in-debt vault which has collateral USDe
.
Swap strategy goes through Curve USDC/USDe
pool.
Owner set slippageToleranceBps = 100 (1%)
(it's minimum).
Assume Chainlink price 1 USDC = 1 USDe
.
Current Curve USDC/USDe Pool reserves on Arbitrum:
USDC - 177_824 USDC - 48.9%
USDe - 185_818 USDe - 51.1%
inDebtVaultCollateralAsset
amount to rebalance = 10_000 USDe
.
expectedAmountOut = 10_000 USDC
because of Chainlink price.
amountOutMinimum = 9900 USDC
because minimum price slippage equals to 1%.
In usual scenario contract will get around 9991 USDC
which is ok.
Attack:
Attacker frontrun rebalanceVaultsAssets()
and imbalance Curve USDC/USDe pool (he will need not much of tokens because pool is small).
Keeper calls rebalanceVaultsAssets()
and swaps 10_000 USDe
for 9900 USDC
.
Attacker takes his tokens and profit back from pool.
Contract instead of 9991 USDC
gets 9900 USDC
.
Protocol takes loss on Curve stable swaps equals around 1% (but if minimum slippage will be set higher by owner, loss will be higher). 1% on small amountIn
is not much in tokens amount, but if amountIn
will be higher, then loss in tokens amount also will be higher.
Manual Review
Consider reducing the minimum slippage tolerance for stable swaps to prevent price manipulation in low-liquidity pools.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.