Sandwich attack on MoneyBrinter_compound allows extracting rewards intended for LPs
The compound function of MoneyBrinter can be sandwiched: an attacker deposits just before a compound call and withdraws just after, capturing most of the rewards that compound distributes to liquidity providers. The attacker profits whenever the extracted value exceeds the withdrawal fee.
Originally disclosed on Immunefi
- Disclosed after under an hour
#42553 [SC-Medium] Sandwich attack on `MoneyBrinter_compound` allows extracting rewards intended for LPs
Submitted on Mar 24th 2025 at 16:06:04 UTC by @OldDingo56530 for Audit Comp | Yeet
- Report ID: #42553
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol
- Impacts:
- Theft of unclaimed yield
Description
Description
The MoneyBrinter::compound function is vulnerable to a sandwich attack that allows an attacker to extract rewards intended for legitimate liquidity providers (LPs).
An attacker can monitor the mempool for compound calls, front-run with a maximal deposit to capture a majority of the share supply, wait for compound to execute, then back-run with an immediate withdrawal to extract the share's inflated value. This attack is atomic within one block and remains profitable as long as the extracted value exceeds the withdrawal fee.
With a sufficient liquidity and infrequent compound calls, a significant amount of rewards will accumulate, making this attack even more lucrative for the attacker.
Recommendation
One solution could be:
- Disallow deposits in the same block as the
compoundcall to prevent front-running
This mitigation prevents the attacker from front-running the compound call with a deposit in the same block. By ensuring that deposits and the compound function cannot be executed in the same block, the attacker is unable to predict and front-run the compound call, rendering the sandwich attack infeasible.
Proof of Concept
Proof of Concept
- Attacker monitors the mempool for upcoming calls to
MoneyBrinter::compoundby the manager. - Attacker front-runs the
compoundcall with a maximal deposit to gain a majority share of theMoneyBrinterLP token supply. - The sandwiched
compoundcall executes, depositing previously harvested rewards fromharvestKodiakRewardsandharvestBeradromeRewards, which increases the underlying share value. - Attacker back-runs the
compoundcall with an immediate withdrawal of their inflated shares, extracting the harvested rewards (minus the 4% fees). - Attacker repeats this attack on all future worth
compoundcalls.
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 compound function increases share value in a single transaction without preventing deposits in the same block, so an attacker can enter just before and exit just after.
Impact
An attacker could steal unclaimed yield meant for liquidity providers; the attack remains profitable only while the extracted value exceeds the 4% withdrawal fee.
What the attacker needed
Ability to submit transactions to the mempool; sufficient capital for a maximal deposit; compound call worth more than the 4% fee
The fix
Deposits should be disallowed in the same block as a compound call, so an attacker cannot front-run it.
How it was found
- Monitor the mempool for upcoming compound calls by the manager.
- Front-run the compound call with a maximal deposit to gain a majority share of the LP token supply.
- Let the compound call execute, which deposits harvested rewards and increases the underlying share value.
- Back-run with an immediate withdrawal of the inflated shares, extracting the harvested rewards minus the 4% fees.
- Repeat on all future worthwhile compound calls.
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 liquidity provider puts money into a pool and earns rewards over time. The compound function adds collected rewards to the pool, raising the value of each share. An attacker can buy shares just before that happens and sell them just after, so most of the new value goes to them instead of the real providers.
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.