#41270 [SC-Medium] Harvest timing exploit enables theft of unclaimed yield
Submitted on Mar 13th 2025 at 07:45:56 UTC by @yesofcourse for Audit Comp | Yeet
Report ID: #41270
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
Brief/Intro
A timing gap in the harvest mechanism of the MoneyBrinter vault allows an attacker to deposit funds at a discounted share price and subsequently withdraw at an elevated share price after unclaimed yield is harvested, effectively enabling the theft of unclaimed yield.
This allows the attacker to profit without providing any long-term liquidity.
The vulnerability could result in significant loss of yield for legitimate depositors, undermining the fairness and efficiency of the protocol.
Vulnerability Details
The vulnerability arises because the MoneyBrinter vault’s deposit and share-minting process is based solely on the vault’s current asset balance, which does not yet include pending rewards nor is there any delay mechanism in place to disallow users to deposit and then withdraw immediately.
When rewards from underlying yield sources (e.g., Beradrome rewards) are accrued, they remain “unharvested” until an explicit harvest operation is performed.
This means that new deposits occurring just before a harvest receive shares calculated at a lower asset value than the eventual post-harvest balance.
An attacker can exploit this timing gap by depositing funds immediately before a harvest - receiving shares at a current price, then triggering the harvest to update the vault’s asset balance, which increases share price, and then withdrawing immediately.
For example, if a legitimate user deposits 10 ether and accrues an additional 1 ether of yield (unharvested), an attacker depositing 1 ether just before the harvest will receive shares at the lower pre-harvest rate. Once the harvest occurs and the vault’s balance increases, the attacker can withdraw their funds at the higher share price, thereby capturing the difference as profit.
Impact Details
The long-term impact is this: imagine some long-term legitimate depositors left their funds to accumulate rewards. An attacker can deposit-havest-withdraw immediately and as a result, get yield without practically committing any funds.
Exploitation of this vulnerability results in the theft of unclaimed yield, leading to a significant and permanent loss of rewards for legitimate depositors.
References
Harvest functions: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol#L159-L185 totalAssets function: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol#L138-L140 From comments in the code:
Rewards can be harvested by anyone. xKDK Rewards can be optionally allocated to Kodiak Rewards Module to harvest more rewards. While compounding, the vault zaps in using the zapper to get island tokens(underling vault asset) and reinvests that into the beradrome farm. The zapper swaps the reward tokens for wBera and Yeet, then mints island tokens and sends them to the vault. It also returns any unused yeet and Wbera to the vault.
Proof of Concept
Proof of Concept
Below is a simple simulated scenario:
Setup Bob deposits 10 ether into the vault, setting the baseline. Then, 1 ether of extra yield is accrued but left unclaimed. At this point the share price is the same.
Attack
An attacker deposits 2 ether, getting shares at the current pre-harvest price.
A harvest is triggered that adds the 1 ether of unclaimed yield to the vault balance.
Attacker immediately withdraws their shares, resulting in an immediate profit.
Here's a runnable POC that simulates the scenario described above. Add this is the VaultDepositTest.t.sol file:
Also add this line in the VaultUnitTest.t.sol file in the initializeVault() so we can use farmPlugin here:
then run with:forge test --match-test testRewardExploit -vvv
Result:
Was this helpful?