Skip to content
Business logic Audit finding Beginner

WethBalanceBefore is computed after withdrawal in _deallocate function in MorphoYearnOGWETHStrategy contract, leading to systematic StrategyDeallocationLoss event emission.

In the strategy's deallocation function, the starting WETH balance is read after the vault withdrawal instead of before it, so the redeemed amount always computes to zero. As a result, a loss event is emitted on every deallocation even though no loss occurred.

Tadev Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

57024 sc low wethbalancebefore is computed after withdrawal in deallocate function in morphoyearnogwethstrategy contract leading to systematic strategydeallocationloss event emission

Submitted on Oct 22nd 2025 at 18:59:02 UTC by @Tadev for Audit Comp | Alchemix V3

Description

Brief/Intro

The MorphoYearnOGWETHStrategy contract implements the _deallocate function as follows:

    function _deallocate(uint256 amount) internal override returns (uint256) {
        vault.withdraw(amount, address(this), address(this));
        uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this));
        uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this));
        uint256 wethRedeemed = wethBalanceAfter - wethBalanceBefore;
        if (wethRedeemed < amount) {
            emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed);
        }
        require(wethRedeemed + wethBalanceBefore >= amount, "Strategy balance is less than the amount needed");
        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;
    }

Contrary to all other strategies in scope, this one computes wethBalanceBefore after calling vault.withdraw . This means wethBalanceBefore == wethBalanceAfter and therefore wethRedeemed == 0. Hence, the line emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, wethRedeemed); is always executed, emitting the event of deallocation loss during each deallocation.

Vulnerability Details

The vulnerability lies in the incorrect logic in _deallocate. The snippet:

        vault.withdraw(amount, address(this), address(this));
        uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this));
        uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this));

should be :

        uint256 wethBalanceBefore = TokenUtils.safeBalanceOf(address(weth), address(this));
        vault.withdraw(amount, address(this), address(this));
        uint256 wethBalanceAfter = TokenUtils.safeBalanceOf(address(weth), address(this));

Impact Details

The impact of this issue is low as it is related to incorrect logic in the contract, leading to wrong emission of events.

Proof of Concept

Proof of Concept

Please copy paste the following test in MorphoYearnOGWETHStrategyTest.t.sol file:

    function testStrategyDeallocationLoss(uint256 amountToAllocate, uint256 amountToDeallocate) public {
        amountToAllocate = bound(amountToAllocate, 1e18, testConfig.vaultInitialDeposit);
        amountToDeallocate = amountToAllocate;

        vm.startPrank(vault);
        deal(WETH, strategy, amountToAllocate);
        bytes memory prevAllocationAmount = abi.encode(0);
        IMYTStrategy(strategy).allocate(prevAllocationAmount, amountToAllocate, "", address(vault));

        uint256 initialRealAssets = IMYTStrategy(strategy).realAssets();
        require(initialRealAssets > 0, "Initial real assets is 0");
        
        bytes memory prevAllocationAmount2 = abi.encode(amountToAllocate);
        vm.warp(block.timestamp + 1 days);
        
        vm.expectEmit(strategy);
        emit StrategyDeallocationLoss("Strategy deallocation loss.", amountToAllocate, 0);
        IMYTStrategy(strategy).deallocate(prevAllocationAmount2, amountToDeallocate, "", address(vault));
        vm.stopPrank();
    }

This test:

  • deposits amountToAllocate in the vault
  • withdraws amountToAllocate 1 day later

Deallocation is successful, but the StrategyDeallocationLoss event is emitted with a value of 0 for the actual reedemed amount, which is incorrect.

The original report as published on Immunefi, by Tadev. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The balance snapshot is taken after the withdrawal call rather than before it, making the before and after values equal.

Impact

The contract emits a misleading loss event on every deallocation, but no funds are lost and the report rates the impact as low.

What the attacker needed

Strategy holds WETH allocated to the vault; caller is the vault

How it was found

  1. Deposit an amount into the vault through the strategy's allocate function
  2. Advance time by one day
  3. Call deallocate for the same amount and observe the loss event emitted with a redeemed value of zero

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A strategy moves money into a vault and later takes it back out. To check how much came back, the code should note the balance before the withdrawal and compare it with the balance afterwards. Here it notes the balance only after the withdrawal, so the two readings are identical and the code wrongly believes nothing was returned.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Tadev

View all

9 more disclosed reports, best first.

More from Alchemix V3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.