The _deallocate function in MorphoYearnOGWETHStrategy reads the wethBalanceBefore after performing the vault withdrawal, resulting in both pre- and post-withdrawal balances being identical. Consequently, the computed wethRedeemed amount will always be zero. This incorrect accounting prevents accurate detection of deallocation losses and could lead to false assumptions about the strategy’s balance integrity in production.
Vulnerability Details
The function _deallocate is designed to withdraw a specific amount from the vault and determine how much WETH was redeemed by comparing the pre- and post-withdrawal balances. However, the code currently measures both balances after the withdrawal operation:
Since both wethBalanceBefore and wethBalanceAfter are captured after the withdrawal, their values will be equal, resulting in:
This causes:
The StrategyDeallocationLoss event to never emit correctly.
Incorrect validation in subsequent require statements, which rely on a faulty wethRedeemed value.
The logical ordering of operations is incorrect, making the redemption calculation and loss detection mechanisms unreliable.
The correct implementation should capture wethBalanceBefore before invoking the vault withdrawal:
Impact Details
This issue leads to incorrect calculation of redeemed WETH during deallocation. Inaccurate accounting can cause:
Missed loss detection: Losses incurred during withdrawals will not be properly identified, making strategy performance tracking and safety checks unreliable.
Faulty state validation: Subsequent require statements may incorrectly pass, allowing further operations under false assumptions of sufficient balance.
Potential accounting mismatch: In production, this could distort internal strategy metrics, mislead monitoring systems, and potentially cause unexpected fund transfer failures or inaccuracies in user-facing reports.
References
Add any relevant links to documentation or code
Proof of Concept
Proof of Concept
Place the following test in MockMorphoYearnOGWETHStrategy.t.sol