Skip to content
Smart contracts Audit finding Intermediate

MoneyBrinter contract is EIP-4626 incompliant

The MoneyBrinter contract's maxWithdraw function does not account for the exit fee, so it returns an amount that cannot actually be withdrawn. An attacker could use this to cause a withdrawal to revert, but the report only shows a test failure, not a real exploit.

trtrth Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#41635 [SC-Low] MoneyBrinter contract is EIP-4626 incompliant

Submitted on Mar 17th 2025 at 07:04:00 UTC by @trtrth for Audit Comp | Yeet

Description

Brief/Intro

The contract MoneyBrinter inherits OZ's ERC4626 contract. However, by customizing some functions, the contract becomes EIP-4626 incompliant

Vulnerability Details

According to EIP-4626 specifications about function maxWithdraw()

Maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call.

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

MUST factor in both global and user-specific limits, like if withdrawals are entirely disabled (even temporarily) it MUST return 0.

MUST NOT revert.

However, the function MoneyBrinter#maxWithdraw() does not take exit fee into account, which can return values that is unable to be withdrawn.

Impact Details

ERC-4626 incompliance: The value returned from maxWithdraw() can not be used to withdraw

References

https://eips.ethereum.org/EIPS/eip-4626#maxwithdraw.

Proof of Concept

Proof of Concept

  1. Modify the test testWithdrawSuccessWithFee at file test/vault/VaultWithdrawTest.t.sol as below:
Solidity
    function testWithdrawSuccessWithFee() public {
        uint256 feeBps = 100; // 1%
        _setExitFee(feeBps);

        uint max = vault.maxWithdraw(bob);

        console.log(max);

        vm.prank(bob);
        vault.withdraw(max, bob, bob);
    }
  1. Run the test and console shows
Bash
  [71669] VaultWithdrawTest::testWithdrawSuccessWithFee()
    ├─ [0] VM::prank(Identity: [0x0000000000000000000000000000000000000004])
    │   └─ ← [Return]
    ├─ [26472] MoneyBrinter::setExitFeeBasisPoints(100)
    │   ├─ emit ExitFeeBasisPointsSet(oldFeeBps: 0, newFeeBps: 100)
    │   └─ ← [Stop]
    ├─ [15095] MoneyBrinter::maxWithdraw(SHA-256: [0x0000000000000000000000000000000000000002]) [staticcall]
    │   ├─ [2918] BeradromeFarmMock::balanceOf(MoneyBrinter: [0xD455fFdBc64B8da6fC1054237a60a8c377aecb72]) [staticcall]
    │   │   └─ ← [Return] 1000000000000000000000000 [1e24]
    │   └─ ← [Return] 1000000000000000000000000 [1e24]
    ├─ [0] console::log(1000000000000000000000000 [1e24]) [staticcall]
    │   └─ ← [Stop]
    ├─ [0] VM::prank(SHA-256: [0x0000000000000000000000000000000000000002])
    │   └─ ← [Return]
    ├─ [11675] MoneyBrinter::withdraw(1000000000000000000000000 [1e24], SHA-256: [0x0000000000000000000000000000000000000002], SHA-256: [0x0000000000000000000000000000000000000002])
    │   ├─ [918] BeradromeFarmMock::balanceOf(MoneyBrinter: [0xD455fFdBc64B8da6fC1054237a60a8c377aecb72]) [staticcall]
    │   │   └─ ← [Return] 1000000000000000000000000 [1e24]
    │   ├─ [918] BeradromeFarmMock::balanceOf(MoneyBrinter: [0xD455fFdBc64B8da6fC1054237a60a8c377aecb72]) [staticcall]
    │   │   └─ ← [Return] 1000000000000000000000000 [1e24]
    │   └─ ← [Revert] ERC20InsufficientBalance(0x0000000000000000000000000000000000000002, 100000000000000000000000000000 [1e29], 101000000000000000000000000000 [1.01e29])
    └─ ← [Revert] ERC20InsufficientBalance(0x0000000000000000000000000000000000000002, 100000000000000000000000000000 [1e29], 101000000000000000000000000000 [1.01e29])

Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 1.33ms (180.88µs CPU time)

Ran 1 test suite in 1.20s (1.33ms CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)

Failing tests:
Encountered 1 failing test in test/vault/VaultWithdrawTest.t.sol:VaultWithdrawTest
[FAIL: ERC20InsufficientBalance(0x0000000000000000000000000000000000000002, 100000000000000000000000000000 [1e29], 101000000000000000000000000000 [1.01e29])] testWithdrawSuccessWithFee() (gas: 71669)

It means that the contract MoneyBrinter is trying to burn more amount than the user's balance

The original report as published on Immunefi, by trtrth. 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 does not subtract the exit fee from the calculated maximum withdrawable amount.

Impact

The value returned from maxWithdraw cannot be used to withdraw, causing a revert; this is an EIP-4626 incompliance, but no direct loss of funds is shown.

What the attacker needed

Exit fee set above zero; user has a balance

How it was found

  1. Set an exit fee of 1% in the test.
  2. Call maxWithdraw for a user and log the result.
  3. Call withdraw with that result for the same user.
  4. Observe the transaction reverts due to insufficient balance.

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.

This is about a smart contract that follows a standard called EIP-4626 for vaults. The standard says a function called maxWithdraw must return the largest amount a user can withdraw without failing. Here, the function ignores a fee, so it gives a number that is too high, and when the user tries to withdraw that amount, the transaction fails.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by trtrth

View all

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

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.