58648 sc low incorrect wethbalancebefore read causes broken loss detection in deallocation
Description
Summary
Vulnerability details
function _deallocate(uint256 amount) internal override returns (uint256) {
vault.withdraw(amount, address(this), address(this)); // Withdrawal happens FIRST
uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this)); // Read AFTER
uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this)); // Same value
uint256 wethRedeemed = wethBalanceAfter - wethBalanceBefore; // Always 0
if (wethRedeemed < amount) {
emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed);
}
require(TokenUtils.safeBalanceOf(address(weth), address(this)) >= amount, "Strategy balance is less than the amount needed");
TokenUtils.safeApprove(address(weth), msg.sender, amount);
return amount;
}Impact
Likelihood
Recommendation
Proof of Concept
Previous57916 sc critical repay removes earmark meant to be reducing debt while collateral is still reducedNext57127 sc low pending admin should call the function instead of admin
Was this helpful?