Skip to content
Business logic Audit finding Beginner

Incorrect maxWithdraw() returns lead to user failed withdrawals of returned maximum amount

The vault's maxWithdraw() reports the full asset value of a user's shares without accounting for the exit fee, so a user withdrawing that reported maximum needs more shares than they hold. The withdrawal therefore reverts, wasting gas and breaking the ERC-4626 promise that maxWithdraw returns an amount that will not revert.

merlinboii Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42539 [SC-Low] Incorrect `maxWithdraw()` returns lead to user failed withdrawals of returned maximum amount

Submitted on Mar 24th 2025 at 15:17:25 UTC by @merlinboii for Audit Comp | Yeet

Description

Brief/Intro

The MoneyBrinter.maxWithdraw() function returns an overestimated value that doesn't account for withdrawal fees, causing withdrawals at the reported maximum to always revert due to insufficient shares balance to burn.

Vulnerability Details

The ERC4626 implementation's maxWithdraw calculates withdrawable assets as:

Solidity
function maxWithdraw(address owner) public view virtual returns (uint256) {
    return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);
}

However, the previewWithdraw() implementation adds a fee:

Solidity
function previewWithdraw(uint256 assets) public view override returns (uint256) {
    uint256 fee = _feeOnRaw(assets, exitFeeBasisPoints);
    return super.previewWithdraw(assets + fee);
}

This creates a mathematical inconsistency where the maxWithdraw() is returned the assets from the shares balance of owner, but the previewWithdraw() returns the shares amount from the assets + fee.

Moreover, this is not compile with EIP-4626 as according to EIP-4626 specifications, maxWithdraw MUST:

  1. Return the maximum amount of assets that could be transferred from owner through withdraw and not cause a revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
  2. MUST factor in both global and user-specific limits, like if withdrawals are entirely disabled (even temporarily) it MUST return 0.
  3. MUST NOT revert.

Impact Details

Low (Contract fails to deliver promised returns, but doesn't lose value)

While no funds are directly at risk, this issue:

  1. Cause failed transactions and wasted gas when users attempt to withdraw their reported maximum
  2. Breaks core EIP-4626 functionality and compliance

References

https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol

https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol#L24

Proof of Concept

Proof of Concept

Initial state:

  • Assume a user has 100 shares in the vault
  • Assume the exchange rate is 1:1 (1 share = 1 asset)
  • Assume exitFeeBasisPoints = 100 (1%)
  1. User queries their maximum withdrawable amount
Solidity
uint256 maxAssets = vault.maxWithdraw(user);
// maxAssets = _convertToAssets(balanceOf(user): 100 shares) = 100 assets
  1. User attempts to withdraw this maximum amount
Solidity
// maxAssets = 100 assets
vault.withdraw(100 assets, user, user);
  1. The withdraw() function will revert because:
Solidity
uint256 maxAssets = maxWithdraw(owner);
// First check PASSES because assets == maxAssets
if (assets > maxAssets) { 
    revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);
}

// Calculate shares needed
uint256 shares = previewWithdraw(assets); // Calculate shares for 100 assets

// Inside previewWithdraw():
uint256 fee = _feeOnRaw(100, 100); // 100 * 100 / 10000 = 1 (with ceiling rounding)
return super.previewWithdraw(100 + 1); // Calculate shares for 101 assets
// shares = 101

// Try to burn 101 shares, but user only has 100
// REVERTS here
@> _withdraw(_msgSender(), receiver, owner, assets: 100, shares: 101);

The transaction reverts because the user needs 101 shares to withdraw 100 assets (query from maxWithdraw()), but they only have 100 shares.

The original report as published on Immunefi, by merlinboii. 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

Likely the maxWithdraw() override converts the owner's share balance to assets without adding the exit fee that previewWithdraw() applies, so the two functions disagree.

Impact

Users attempting to withdraw the reported maximum get failed transactions and wasted gas; no funds are lost, but ERC-4626 compliance is broken.

What the attacker needed

A vault with a non-zero exit fee; user holds shares in the vault

The fix

maxWithdraw() should be adjusted so it accounts for the exit fee and underestimates rather than overestimates, matching what previewWithdraw() will actually require.

How it was found

  1. Query the vault's maxWithdraw() for the user's address, which returns the full asset value of their shares.
  2. Call withdraw() with that reported maximum amount.
  3. The max check passes, but previewWithdraw() adds the fee and computes more shares than the user holds.
  4. The internal withdraw tries to burn those shares and reverts.

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 vault lets people deposit and later take their money back, and it charges a small fee when they withdraw. A helper function is supposed to tell you the largest amount you can safely withdraw, but it forgets to include the fee, so it gives a number that is slightly too big. When you try to take that amount, the vault needs more of your deposit units than you own and the transaction fails.

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 merlinboii

View all

9 more disclosed reports, best first.

More from Yeet

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.