Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: medium
Valid

Use `safeTransferFrom()` instead of `transferFrom()` for outgoing ERC-721 transfers

Summary

It’s advisable to opt for safeTransferFrom() instead of transferFrom() when sending ERC721 tokens from the vault to external address

Vulnerability Details

Currently, the contract uses transferFrom() instead of safeTransferFrom() — presumably to reduce gas costs. However, this approach has its drawbacks. According to OpenZeppelin’s ERC721 documentation, using safeTransferFrom() is the much preferred method. It adds additional safety checks that transferFrom() lacks.

Impact

Although the risk is minimal in this case (since the recipient is the transaction initiator), there remains a chance that tokens could be permanently lost if sent to a contract that doesn’t support ERC721 transfers correctly.

Recommendations

Use safeTransferFrom() when sending out the NFT from the vault.

- eggNFT.transferFrom(address(this), msg.sender, tokenId);
+ eggNFT.safeTransferFrom(address(this), msg.sender, tokenId);
Updates

Lead Judging Commences

m3dython Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Unsafe ERC721 Transfer

NFTs are transferred to contracts without onERC721Received implementation.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.