The EggVault
contract fails to implement the onERC721Received
interface, which is required for contracts to safely receive ERC721 tokens (NFTs) via the safeTransferFrom
function. This omission prevents users from using the recommended safe transfer methods to deposit their NFTs into the vault, forcing them to use the less secure transferFrom
method instead.
The ERC721 standard (EIP-721) defines two transfer methods:
transferFrom
- A basic transfer that does not check if the receiver can handle ERC721 tokens
safeTransferFrom
- A safer transfer method that verifies the receiver's ability to handle ERC721 tokens
When safeTransferFrom
is called, the ERC721 contract checks if the recipient is a contract. If it is, it calls the onERC721Received
function on the recipient and verifies that the correct magic value (bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
) is returned.
The EggVault
contract is designed to hold NFTs but does not implement this required function:
Without this implementation, any calls to safeTransferFrom
with the vault as the receiver will fail, even though the vault is specifically designed to hold these tokens.
This vulnerability has several negative impacts:
Restricted Transfer Options: Users are forced to use the less secure transferFrom
method instead of the safer safeTransferFrom
method.
Integration Failures: Many modern NFT platforms and wallets use safeTransferFrom
by default, which would fail when interacting with this vault.
Bad User Experience: Users attempting to use safe transfer methods will encounter errors, leading to confusion and friction.
Manual Review
Use OpenZeppelin's Implementation: Consider inheriting from OpenZeppelin's ERC721Holder
contract, which provides a standard implementation of this interface:
NFTs are transferred to contracts without onERC721Received implementation.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.