NFTXStakingZap and NFTXMarketplaceZap’s transferFromERC721 transfer Cryptokitties to the wrong address
The transferFromERC721 function in NFTXStakingZap and NFTXMarketplaceZap sends Cryptokitties NFTs to the contract itself instead of the intended recipient. This causes the NFT to be missing from the vault, leading to incorrect accounting.
Submitted by hyh
transferFromERC721(address assetAddr, uint256 tokenId, address to) should transfer from msg.sender to to. It transfers to address(this) instead when ERC721 is Cryptokitties. As there is no additional logic for this case it seems to be a mistake that leads to wrong NFT accounting after such a transfer as NFT will be missed in the vault (which is to).
Proof of Concept
NFTXStakingZap: transferFromERC721 https://github.com/code-423n4/2021-12-nftx/blob/main/nftx-protocol-v2/contracts/solidity/NFTXStakingZap.sol#L416
NFTXMarketplaceZap: transferFromERC721 https://github.com/code-423n4/2021-12-nftx/blob/main/nftx-protocol-v2/contracts/solidity/NFTXMarketplaceZap.sol#L556
Both functions are called by user facing Marketplace buy/sell and Staking addLiquidity/provideInventory functions.
Recommended Mitigation Steps
Fix the address:
Now:
// Cryptokitties.
data = abi.encodeWithSignature("transferFrom(address,address,uint256)", msg.sender, address(this), tokenId);
To be:
// Cryptokitties.
data = abi.encodeWithSignature("transferFrom(address,address,uint256)", msg.sender, to, tokenId);
0xKiwi (NFTX) confirmed, but disagreed with medium severity and commented:
This was intentional, as I thought it was needed for the contract to require custody, but it should work fine to send directly to the vault.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
Cryptokitties NFTs sent via these functions end up stuck in the contract rather than the vault, causing incorrect NFT accounting; the text does not describe any direct theft or loss beyond this misplacement.
What the attacker needed
Using Cryptokitties NFTs; calling buy/sell or addLiquidity/provideInventory
The fix
The code was fixed to send the NFT to the 'to' address instead of the contract itself.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you send an NFT to a vault, the code should deliver it to the vault's address. For one special NFT type (Cryptokitties), the code mistakenly sends it to the contract's own address instead. That means the vault never receives the NFT, so records are wrong.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.