TokenTransferrer is using unsafe transferFrom for ERC721 instead of safeTransferFrom. Necessary checks will be skipped! #173
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/code-423n4/2022-05-opensea-seaport/blob/4140473b1f85d0df602548ad260b1739ddd734a5/contracts/lib/TokenTransferrer.sol#L220-L327
https://github.com/Chomtana/2022-05-opensea-seaport/blob/8b4009bc3d81fc753a0e8435470a22505f25c411/test/index.js#L16275-L16323
Vulnerability details
Impact
TokenTransferrer is using unsafe transferFrom for ERC721 instead of safeTransferFrom. Necessary checks will be skipped!
Necessary checks include
_data
bytes.If these checks fail, transaction will be reverted. This is done to prevent the loss of NFT because of transferring into a contract that cannot receive ERC721.
But TokenTransferrer is using unsafe transferFrom which doesn't perform these check, so NFT may be transferred into a contract that cannot receive ERC721.
Moreover, with special
DataRestricted NFT
, a NFT that can only be transferred if and only if valid_data
bytes is specified. Seaport can't handle this kind of NFT at all cost because_data
bytes is only available onsafeTransferFrom
. This kind of NFT is likely block unsafetransferFrom
function from being used.Data restricted NFT has use case in GameFi where every transfer must be approved by the offchain backend.
You can find implementation of Data restricted NFT below
More detail: https://anallergytoanalogy.medium.com/jumping-into-solidity-the-erc721-standard-part-4-ad21e3a5d9c
Proof of Concept
Assembly code in _performERC721Transfer in TokenTransferrer clearly state that Seaport use unsafe
transferFrom
as shown belowFurthermore, my new testcases show a revert message which indicate Seaport is calling unsafe
transferFrom
function which is blocked in DataRestrictedNft721 implementationhttps://github.com/Chomtana/2022-05-opensea-seaport/blob/8b4009bc3d81fc753a0e8435470a22505f25c411/test/index.js#L16275-L16323
The DataRestrictedNft721 implementation: https://github.com/Chomtana/2022-05-opensea-seaport/blob/main/contracts/attack/DataRestrictedNFT721.sol is blocking unsafe
transferFrom
usingThis testcase is passed, which is a proof that Seaport use unsafe
transferFrom
instead ofsafeTransferFrom
Tools Used
Fork codebase and create special NFT and then create more testcase to check for reverted message.
More testcases created at https://github.com/Chomtana/2022-05-opensea-seaport/blob/8b4009bc3d81fc753a0e8435470a22505f25c411/test/index.js#L16275-L16323
Recommended Mitigation Steps
Use safeTransferFrom instead of transferFrom.
The text was updated successfully, but these errors were encountered: