57599 sc low protocol wrongly withdraws before checking balance of withdraw
Description
Brief/Intro
Vulnerability Details
function _deallocate(uint256 amount) internal override returns (uint256) {
vault.withdraw(amount, address(this), address(this));
// BUG: Both balance checks happen AFTER the withdrawal.
uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this));
uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this));
// `wethRedeemed` will always be 0 as `wethBalanceAfter` equals `wethBalanceBefore`.
uint256 wethRedeemed = wethBalanceAfter - wethBalanceBefore;
if (wethRedeemed < amount) {
emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed);
}
// This check becomes `require(wethBalanceAfterWithdrawal >= amount)`
require(wethRedeemed + wethBalanceBefore >= amount, "Strategy balance is less than the amount needed");
}Impact Details
References
Proof of Concept
Proof of Concept
Previous57308 sc high alchemistv3 does not update mytsharesdeposited when performing liquidation causing global accounting and liquidation logic mismatchNext58492 sc medium unbounded deposit exposure in tokeautoethstrategy allocate
Was this helpful?