Skip to content
Business logic Audit finding Intermediate

MoneyBrinter vault does not conform to ERC4626

The vault's maxWithdraw function returns an amount that does not account for exit fees, so withdrawing that amount reverts. This breaks ERC4626 compliance and may cause external integrations to fail.

NHristov Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42604 [SC-Low] `MoneyBrinter` vault does not conform to ERC4626

Submitted on Mar 24th 2025 at 23:12:58 UTC by @NHristov for Audit Comp | Yeet

Description

Brief/Intro

Vault’s implementation of ERC4626 returns an incorrect value in maxWithdraw when exit fees are applied. If a user attempts to withdraw using the maxWithdraw value, the transaction will revert, which means that the vault does not fully conform to the expected ERC4626 standard.

Vulnerability Details

The ERC4626 specification states that the maxWithdraw function MUST 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). but the current MoneyBrinter contract does not conform this statement when fees are applied on withdraw.

The calculation of the fees can be found in the following MoneyBrinter functions.

Solidity
function previewWithdraw(uint256 assets) public view override returns (uint256) {
    uint256 fee = _feeOnRaw(assets, exitFeeBasisPoints);
    return super.previewWithdraw(assets + fee);
}
Solidity
function _feeOnRaw(uint256 assets, uint256 feeBasisPoints) private pure returns (uint256) {
    return assets.mulDiv(feeBasisPoints, _BASIS_POINT_SCALE, Math.Rounding.Ceil);
}

but the maxWithdraw function is not overriden by the default implementation of the ERC4626 Openzeppelin contract.

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

This shows that maxWithdraw produces an amount that cannot be successfully withdrawn due to the fee calculation, and thus the vault fails to meet the requirements of ERC4626 and leads to transactions being reverted.

Impact Details

MoneyBrinter does not conform to ERC4626 which may break external integrations and leading to failed transactions.

References

ERC4626 documentation - https://eips.ethereum.org/EIPS/eip-4626#maxWithdraw

Proof of Concept

Proof of Concept

The following test could be added to the VaultWithdrawTest.t test file.

Solidity
function testMaxWithdrawReturnsIncorectValueWhenFeeIsApplied() public {
    uint256 feeBps = 1000; // 1%
    _setExitFee(feeBps);

    uint256 withdrawAmount = vault.maxWithdraw(bob);

    // we expect to revert with ERC4626ExceededMaxWithdraw
    vm.expectRevert();
    vm.prank(bob);
    vault.withdraw(withdrawAmount, bob, bob);
}

this can be executed by running the command:

forge test --mt testMaxWithdrawReturnsIncorectValueWhenFeeIsApplied -vvvv

Here, even though vault.maxWithdraw(bob) returns 100 tokens, this amount does not account for the exit fee. When the user calls vault.withdraw with this amount, the fee is added on, causing the withdrawal to exceed the available balance, which ultimately reverts the transaction.

The original report as published on Immunefi, by NHristov. 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 function was not overridden to subtract the exit fee, so it returns a value that is higher than what can actually be withdrawn.

Impact

The vault does not conform to ERC4626, which may break external integrations and lead to failed transactions.

What the attacker needed

Exit fee is set above zero

How it was found

  1. Set an exit fee on the vault.
  2. Call maxWithdraw for a user to get the reported maximum.
  3. Attempt to withdraw that exact amount as the user.
  4. Observe that the transaction 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 is a smart contract that holds assets for users. The ERC4626 standard says a function called maxWithdraw must return the largest amount a user can withdraw without the transaction failing. Here, because a fee is added during withdrawal, the reported maximum is too high, so trying to withdraw that exact amount causes an error.

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 NHristov

View all

6 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.