# treasury is vulnerable to sandwich attack

Permissionless veCRVlock() in MochiTreasury lets an attacker flashloan-buy CRV, trigger the treasury's CRV purchase at inflated price, then sell for profit.

- Payout: Audit contest
- Severity: high
- Program: Mochi
- Disclosed: 2021-11-23
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2021-10-mochi-findings/issues/60
- Library page: https://bugbountylibrary.com/r/c4%3A2021-10-mochi%3AH-09
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity vuln:business-logic vuln:oracle-manipulation

**Target:** MochiTreasuryV0 veCRVlock() function / Uniswap CRV pool
**Root cause:** veCRVlock() is callable by anyone and performs a market CRV purchase, so an attacker can manipulate the pool price around the treasury's buy.
**Steps:**
1. Flashloan and buy CRV on the Uniswap pool to push price up
2. Call `veCRVlock()` on MochiTreasuryV0
3. Treasury buys CRV at the inflated price
4. Sell CRV back, repay flashloan, keep profit
**How found:** Noticed veCRVlock() lacked access control and executed a market swap, making it sandwichable by any caller.
**Exploitation:** Attacker flashloans capital, front-runs the treasury's CRV purchase by buying CRV on Uniswap, triggers the permissionless veCRVlock() so the treasury buys at the manipulated high price, then sells CRV to capture the spread and repays the loan.
**Insight:** Any permissionless function that performs a market swap on a DEX is a sandwich target: check treasury/keeper functions for missing onlyOwner plus AMM interaction.
