# Anyone can withdraw user's Velo Deposit NFT after approval is given to depositor

Depositor.withdrawFromGauge is callable by anyone and pays msg.sender, so after a user approves the Depositor to burn their NFT, an attacker front-runs and steals the withdrawn tokens.

- Payout: Contest reward
- Severity: high
- Program: Isomorph
- Credited: HonorLt
- Disclosed: 2022-11-05
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2022-11-isomorph-judging/issues/47
- Library page: https://bugbountylibrary.com/r/sherlock%3A2022-11-isomorph%3AH-8
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:race-window technique:source-review vuln:access-control vuln:business-logic

**Target:** Depositor.sol withdrawFromGauge (Velo Deposit NFT / gauge)
**Root cause:** withdrawFromGauge is public, burns the NFT via depositReceipt.burn (which only requires the caller be owner or approved) and transfers the withdrawn AMMToken to msg.sender without verifying msg.sender owns the NFT.
**Steps:**
1. User A deposits underlying and receives Deposit NFT (Token A).
2. User A calls `depositReceipt.approve(Depositor, NFTId)` in a separate tx to enable withdrawal.
3. Attacker B observes the approval and calls `Depositor.withdrawFromGauge(NFTId, tokens)` first.
4. Depositor burns NFT (approved), calls `gauge.withdraw(amount)`, and `AMMToken.transfer(msg.sender=B, amount)`.
5. User A's NFT is burned and the 100 underlying tokens go to B.
**How found:** Code review of withdrawFromGauge: noticed it is public, pays msg.sender, and relies on burn's _isApprovedOrOwner check, implying approval must happen in a prior transaction — creating a front-runnable window.
**Exploitation:** Attacker monitors mempool/state for approvals or transfers of Deposit NFTs to the Depositor, then front-runs the legitimate withdrawFromGauge call; since the function pays msg.sender and burn only checks approval, the attacker receives the full withdrawn amount while the victim's NFT is burned. Easily automated with a bot.
**Insight:** When a withdraw/redeem function pays msg.sender but relies on a separate prior approval/transfer to satisfy an NFT burn check, the approval window is a front-running theft vector; check that payout recipient is bound to NFT ownership.
