57079 sc low h 1 morphoyearnogweth strategy incorrect balance measurement order in deallocate causes dos on withdrawals with any loss

Submitted on Oct 23rd 2025 at 09:40:00 UTC by @Aizen09 for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #57079

  • Report Type: Smart Contract

  • Report severity: Low

  • Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/strategies/mainnet/MorphoYearnOGWETH.sol

  • Impacts:

    • Temporary freezing of funds for at least 1 hour

Description

Summary

The MorphoYearnOGWETHStrategy._deallocate() function measures balance AFTER withdrawal instead of BEFORE, causing wethRedeemed to always be 0 and making the function revert on any withdrawal loss.

Vulnerability Details

Location: src/strategies/mainnet/MorphoYearnOGWETH.sol lines 49-56

Buggy Code:

function _deallocate(uint256 amount) internal override returns (uint256) {
    vault.withdraw(amount, address(this), address(this));  // Line 49: Withdrawal happens HERE
    uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this));  // Line 50: Measured AFTER withdrawal
    uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this));   // Line 51: Same value!
    uint256 wethRedeemed = wethBalanceAfter - wethBalanceBefore;  // Line 52: Always 0
    if (wethRedeemed < amount) {
        emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed);
    }
    require(wethRedeemed + wethBalanceBefore >= amount, "Strategy balance is less than the amount needed");  // Line 56: Will fail
    ...
}

Root Cause

Lines 50-51 both measure balance AFTER the withdrawal (line 49), making them equal. Therefore wethRedeemed = 0 always.

Impact

Severity: HIGH - Denial of Service

  1. Any deallocate with slippage/loss will revert

  2. Cannot withdraw from strategy when market conditions cause losses

  3. Funds stuck in strategy

  4. Protocol cannot rebalance allocations

Proof of Concept

How to run the POC:

Scenario: Deallocate 100 WETH with 2 WETH loss

Execution Flow:

Expected: wethRedeemed should be 98 (actual received amount) Actual: wethRedeemed is 0, causing revert

Code Comparison

Correct Implementation (TokeAutoEth):

Buggy Implementation (MorphoYearn):

Recommendation

Move the wethBalanceBefore measurement BEFORE the withdrawal:

Proof of Concept

Proof of Concept

Was this helpful?