58424 sc low morphoyearnogweth strategy balance check order bug
Description
Summary
Vulnerable Code
function _deallocate(uint256 amount) internal override returns (uint256) {
vault.withdraw(amount, address(this), address(this)); // Line 50 ← WITHDRAW FIRST
uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this)); // Line 51 ← AFTER withdraw!
uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this)); // Line 52 ← SAME!
uint256 wethRedeemed = wethBalanceAfter - wethBalanceBefore; // Line 53 ← = 0!
if (wethRedeemed < amount) { // Line 54 ← Always true
emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed);
}
require(wethRedeemed + wethBalanceBefore >= amount, "Strategy balance is less than the amount needed");
// ...
}The Problem
Comparison with Correct Implementation
2. Impact Analysis
Direct Consequences
Secondary Impact
Proof of Concept
3. Proof of Concept
Test Case
Observed Behavior
Previous58110 sc low morphoyearnogwethstrategy will always report strategy lossNext57975 sc low broken admin rotation in acceptadminownership causes permanent governance lockout
Was this helpful?