# Tokens Can Be Stolen By Frontrunning VestedRewardPool.vest() and VestedRewardPool.lock()

VestedRewardPool.vest()/lock() pull tokens via transferFrom without binding the deposit to the recipient, letting an attacker frontrun and steal the vested mochi.

- Payout: Audit contest
- Severity: high
- Program: Mochi
- Found by: leastwood
- Disclosed: 2021-11-23
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2021-10-mochi-findings/issues/92
- Library page: https://bugbountylibrary.com/r/c4%3A2021-10-mochi%3AH-13
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:race-window technique:source-review vuln:business-logic

**Target:** VestedRewardPool.sol vest()/lock() emission contract
**Root cause:** vest() and lock() do not use safeTransferFrom and do not bind the transferred tokens to the intended recipient, so the deposit is credited to whoever the caller specifies rather than the payer.
**Steps:**
1. Observe a victim's pending `vest(amount, recipient)` transaction in the mempool.
2. Frontrun with `vest(amount, attacker)` (or `lock`) so the attacker's address is credited with the vested position.
3. Victim's transferFrom pulls their mochi into the pool but the vesting entry belongs to the attacker.
4. Attacker waits out the 90-day vest and withdraws the stolen mochi.
**How found:** Manual code review of the public-facing vesting contract; noticed vest()/lock() lacked safeTransferFrom and did not tie the deposit to the caller/recipient, then reasoned about mempool frontrunning.
**Exploitation:** Attacker watches the mempool for a vest()/lock() call, submits an identical call with their own address as recipient at higher gas, causing the victim's tokens to be transferred into a position owned by the attacker.
**Insight:** In vesting/staking contracts, check whether the deposit path binds the payer to the credited position; any public function taking a recipient parameter and pulling funds via transferFrom is frontrunnable to redirect the credit.
