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.
- 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
- Report ID: #57024
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/strategies/mainnet/MorphoYearnOGWETH.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
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
amountToAllocatein the vault - withdraws
amountToAllocate1 day later
Deallocation is successful, but the StrategyDeallocationLoss event is emitted with a value of 0 for the actual reedemed amount, which is incorrect.
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
- Deposit an amount into the vault through the strategy's allocate function
- Advance time by one day
- 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.