58645 sc medium incorrect weth wrapping amount in moonwellwethstrategy deallocate wraps ethredeemed instead of amount
Description
Brief/Intro
Vulnerability Details
function _deallocate(uint256 amount) internal override returns (uint256) {
uint256 ethBalanceBefore = address(this).balance; // Track before redemption
// Pull exact amount of underlying WETH out
mWETH.redeemUnderlying(amount); // Returns ETH, not WETH
// wrap any ETH received (Moonwell redeems to ETH for WETH markets)
uint256 ethBalanceAfter = address(this).balance;
uint256 ethRedeemed = ethBalanceAfter - ethBalanceBefore; // Calculate redeemed ETH
if (ethRedeemed < amount) {
emit StrategyDeallocationLoss("Strategy deallocation loss.", amount, ethRedeemed);
}
if (ethRedeemed + ethBalanceBefore >= amount) {
weth.deposit{value: ethRedeemed}(); // Wrap only if condition passes
}
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;
}Impact Details
References
Recommendation
Proof of Concept
Proof of Concept
Previous57963 sc high incorrect mytsharesdeposited accounting in liquidate allows theft of user funds via corrupted bad debt ratioNext58138 sc critical liquidator fees could surpass the user remaining collateral resulting in protocol insolvency
Was this helpful?