# CryptoPunks NFTs may be stolen via deposit frontrunning

Ajna ERC721Pool.addCollateral buys CryptoPunks via buyPunk without checking caller is owner, letting anyone frontrun a deposit and steal the NFT.

- Payout: Contest reward
- Severity: high
- Program: Ajna
- Credited: Jeiwan
- Disclosed: 2022-12-21
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2023-01-ajna-judging/issues/140
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AH-3
- 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:** ERC721Pool.addCollateral / CryptoPunks buyPunk
**Root cause:** addCollateral calls CryptoPunks buyPunk and credits the caller, but never verifies msg.sender owns the punk; the sale offer's onlySellTo is the pool, so any caller can trigger the purchase.
**Steps:**
1. Owner calls `offerPunkForSaleToAddress(punkIndex, minPrice, poolAddress)` to list punk for the pool.
2. Owner submits `addCollateral(tokenId)` to deposit.
3. Attacker frontruns with their own `addCollateral(tokenId)` call.
4. Pool calls `buyPunk(tokenId)`, pays the owner, and records the punk as collateral for the attacker.
5. Attacker withdraws the NFT from the pool to their account.
**How found:** Code reading: noticed CryptoPunks lacks ERC721 so deposit uses direct sale via buyPunk, and that addCollateral has no ownership check on msg.sender, enabling frontrunning.
**Exploitation:** Attacker observes the victim's offerPunkForSaleToAddress + addCollateral in mempool, submits addCollateral first; pool buys the punk (onlySellTo matches pool) and credits attacker's account, who then withdraws it.
**Insight:** When a protocol integrates a non-standard NFT (CryptoPunks) via a marketplace buy instead of transferFrom, the buy credits whoever calls it—check that the deposit path binds the caller to the token owner, since the sale's onlySellTo only restricts the buyer to the pool, not the depositor.
