Protocol fee loss due to incorrect fee calculation in MoneyBrinter.sol
The contract's fee calculation for withdrawals and redemptions undercharges the exit fee because it adds the fee to the asset amount before converting to shares, resulting in an effective fee lower than intended. An attacker could repeatedly withdraw to pay less fee than expected, causing a loss of protocol fee revenue.
- Disclosed after under an hour
#41873 [SC-Insight] Protocol fee loss due to incorrect fee calculation in MoneyBrinter.sol
Submitted on Mar 19th 2025 at 03:16:10 UTC by @OxSimao for Audit Comp | Yeet
- Report ID: #41873
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
MoneyBrinter.sol incorrectly undercharges borrowing fee due to a math error.
Vulnerability Details
MoneyBrinter.sol implements previewWithdraw() and previewRedeem() and calculates the result including the exit fee, exitFeeBasisPoints. However, this calculation is incorrect.
Suppose there are 1000 assets and shares, user wants to withdraw 100 assets and calls withdraw(), internally calling previewWithdraw() to calculate the fee. feeBasisPoints is 1000 (10%) and _BASIS_POINT_SCALE is 1e4.
uint256 fee = assets * feeBasisPoints / _BASIS_POINT_SCALE = 100 * 1000 / 10000 = 10;
return super.previewWithdraw(assets + fee) = super.previewWithdraw(100 + 10) = 110 * totalSupply / totalAssets = 110 * 1000 / 1000 = 110;
So, calling previewWithdraw() with 100 assets returns 110 shares. However, this fee is smaller than feeBasisPoints = 10%, as 110 shares should give 110 * 0.9 = 99 shares, which is 99 assets also given same total supply and total assets. The actual fee applied is:
- 110 shares are worth 110 assets;
- out of 110 assets, 100 assets are withdrawn
1 - 100/110 = 0.091, so the fee is actually9.1%. This represents a0.9%fee loss.
Issue is similar for previewRedeem().
function previewWithdraw(uint256 assets) public view override returns (uint256) {
uint256 fee = _feeOnRaw(assets, exitFeeBasisPoints);
return super.previewWithdraw(assets + fee);
}
function previewRedeem(uint256 shares) public view override returns (uint256) {
uint256 assets = super.previewRedeem(shares);
return assets - _feeOnTotal(assets, exitFeeBasisPoints);
}
Impact Details
Significant fee loss, if fee is 10%, actual fee is 9.1%, showing a 0.9% fee loss.
References
Proof of Concept
Proof of Concept
Described in the report above but it boils down to:
- User calls
MoneyBrinter::withdraw(), but instead of paying an exit fee of10%, pays9.1%.
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 fee is added to the asset amount before converting to shares, but the fee should be calculated on the total shares needed to cover both the withdrawal and the fee.
Impact
The protocol loses a portion of its exit fee revenue, with the example showing a 0.9% loss when the intended fee is 10%.
What the attacker needed
None
How it was found
- User calls MoneyBrinter::withdraw() with 100 assets.
- The contract calculates a fee of 10 assets (10% of 100).
- It then calls super.previewWithdraw(110) which returns 110 shares.
- The user effectively pays only 9.1% fee instead of 10%.
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 a smart contract bug where the fee charged when you take money out is calculated incorrectly. Instead of charging the full 10% fee, the code effectively charges only about 9.1%, so the protocol loses money each time someone withdraws.
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.