treasury is vulnerable to sandwich attack
A permissionless function in the treasury allowed anyone to trigger a large CRV purchase, which an attacker could sandwich with a flash loan to profit at the treasury's expense. The attacker could potentially steal all funds in the treasury.
Submitted by jonah1005
Impact
There’s a permissionless function veCRVlock in MochiTreasury. Since everyone can trigger this function, the attacker can launch a sandwich attack with flashloan to steal the funds. MochiTreasuryV0.sol#L73-L94
Attackers can possibly steal all the funds in the treasury. I consider this is a high-risk issue.
Proof of Concept
Here’s an exploit pattern
- Flashloan and buy CRV the uniswap pool
- Trigger
veCRVlock() - The treasury buys CRV at a very high price.
- Sell CRV and pay back the loan.
Recommended Mitigation Steps
Recommend to add onlyOwner modifier.
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 function that performs a large token purchase lacked access control, allowing anyone to trigger it and manipulate the market around it.
Impact
Attackers could potentially steal all funds in the treasury.
What the attacker needed
Ability to call a public function; flash loan availability; liquidity in the Uniswap pool
The fix
The function should be restricted to the owner by adding an onlyOwner modifier.
How it was found
- Borrow funds via flash loan and buy CRV on the Uniswap pool.
- Call the veCRVlock function.
- The treasury buys CRV at the inflated price.
- Sell the CRV and repay the flash loan.
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 sandwich attack is when someone sees a large trade coming and places their own trades just before and after it to profit from the price change. Here, a treasury function that buys a token could be called by anyone, so an attacker could use borrowed money to push the price up, let the treasury buy at the inflated price, then sell and repay the loan, keeping the difference.
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.