-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
3 (High Risk)Assets can be stolen/lost/compromised directlyAssets can be stolen/lost/compromised directly🤖_19_groupAI based duplicate group recommendationAI based duplicate group recommendationbugSomething isn't workingSomething isn't workingduplicate-32satisfactorysatisfies C4 submission criteria; eligible for awardssatisfies C4 submission criteria; eligible for awardsupgraded by judgeOriginal issue severity upgraded from QA/Gas by judgeOriginal issue severity upgraded from QA/Gas by judge
Description
Lines of code
Vulnerability details
Vulnerability details
in _payDebt() will perform the following steps
- calculate how much
amountInis needed to pay backdebtAmount + feeby using thequoteExactOutputSingle()method - call _withdraw(amountIn) to retrieve
ierc20A. - call _swap(maxAmountIn = amountIn) to get
debtAmount + fee.
function _payDebt(uint256 debtAmount, uint256 fee) internal {
_repay(wETHA(), debtAmount);
// Get a Quote to know how much collateral i require to pay debt
(uint256 amountIn, , , ) = uniQuoter().quoteExactOutputSingle(
@> IQuoterV2.QuoteExactOutputSingleParams(ierc20A(), wETHA(), debtAmount + fee, 500, 0)
);
@> _withdraw(ierc20A(), amountIn, address(this) );
uint256 output = _swap(
ISwapHandler.SwapParams(
ierc20A(),
wETHA(),
ISwapHandler.SwapType.EXACT_OUTPUT,
@> amountIn,
debtAmount + fee,
_swapFeeTier,
bytes("")
)
);
// When there are leftovers from the swap, deposit then back
uint256 wethLefts = output > (debtAmount + fee) ? output - (debtAmount + fee) : 0;
if (wethLefts > 0) {
_supply(wETHA(), wethLefts);
}
emit StrategyUndeploy(msg.sender, debtAmount);
}The first step to get amountIn uses the real time price, then in the third step the amountIn is used as the Max Amount In.
It's all real-time pricing, and there is no slippage protection
Impact
vault.rebalance()->strategy.harvest() ->_adjustDebt()->_payDebt() Sandwich attack to manipulate prices
Recommended Mitigation
Adding slippage protection: range calculation via TWAP prices
Assessed type
Context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3 (High Risk)Assets can be stolen/lost/compromised directlyAssets can be stolen/lost/compromised directly🤖_19_groupAI based duplicate group recommendationAI based duplicate group recommendationbugSomething isn't workingSomething isn't workingduplicate-32satisfactorysatisfies C4 submission criteria; eligible for awardssatisfies C4 submission criteria; eligible for awardsupgraded by judgeOriginal issue severity upgraded from QA/Gas by judgeOriginal issue severity upgraded from QA/Gas by judge