Vault::takeFees can be front run to minimize accruedPerformanceFee
The vault's performance fee is calculated from a high-water mark that is updated on every deposit, mint, or withdraw. An attacker can front-run fee collection with a dust deposit or withdrawal to reset the high-water mark and eliminate the accrued performance fee.
Submitted by immeas, also found by minhtrng, bin2chen, KIntern_NA, rbserver, ustas, rvierdiiev, and yellowBirdy
performanceFee is a fee on the profits of the vault. The feeRecipient (or any user) can collect these at any point.
They rely on the difference between the current share value and the highWaterMark that records a historical share value.
The issue is that this highWaterMark is written on interactions with the vault: deposit, mint, withdraw. Hence a user can front run the fee collection with any of these calls. That will set the highWaterMark to the current share value and remove the performance fee.
Impact
A malicious user can maximize the yield and deny any performance fee by front running the fee collection with a call to either deposit, mint or withdraw with only dust amounts.
Proof of Concept
PoC test in Vault.t.sol
function test__front_run_performance_fee() public {
_setFees(0, 0, 0, 1e17); // 10% performance fee
asset.mint(alice, 1e18);
vm.startPrank(alice);
asset.approve(address(vault), 1e18);
vault.deposit(1e18);
vm.stopPrank();
asset.mint(address(adapter),1e18); // fake yield
// performanceFee is 1e17 (10% of 1e18)
console.log("performanceFee before",vault.accruedPerformanceFee());
vm.prank(alice);
vault.withdraw(1); // malicious user withdraws dust which triggers update of highWaterMark
// performanceFee is 0
console.log("performanceFee after",vault.accruedPerformanceFee());
}
Tools Used
VS Code, Forge
Recommended Mitigation Steps
At every deposit, mint, redeem and withdraw, take fees before adding or removing the new users shares and assets.
RedVeil (Popcorn) acknowledged
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
The high-water mark is updated on every deposit, mint, and withdraw, allowing it to be reset to the current share value before fees are accrued.
Impact
A malicious user can deny the performance fee and maximise their yield by front-running fee collection with a dust deposit or withdrawal.
What the attacker needed
A vault with a performance fee set; ability to make a deposit or withdrawal
The fix
Fees should be taken before adding or removing shares and assets on every deposit, mint, redeem, and withdraw.
How it was found
- Set a performance fee on the vault.
- Deposit funds and simulate yield so a performance fee accrues.
- Withdraw a dust amount to trigger an update of the high-water mark.
- Observe that the accrued performance fee is now zero.
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 performance fee is a cut of the profit a vault makes. The vault tracks the highest value each share has reached, called the high-water mark, and only charges a fee on gains above that. The bug is that any small deposit or withdrawal updates this mark to the current value, so someone can do that just before the fee is taken and wipe out the fee.
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.