The provided Huff smart contract implements an NFT minting function similar to the ERC721 standard but lacks the necessary checks to ensure that the recipient address can correctly handle the receipt of an ERC721 token. This omission can lead to tokens being permanently locked if they are sent to a contract that does not implement the onERC721Received() function as specified in the ERC721 standard.
The vulnerability arises from the absence of a check to confirm that the recipient contract has a properly implemented onERC721Received()
function. This function is a hook that is called on the recipient contract upon the transfer of an ERC721 token, allowing the contract to handle or reject the transfer.
If an ERC721 token is transferred to a contract that does not have the onERC721Received()
, the token transfer will still be considered successful by the smart contract. This can result in the token being locked within the recipient contract with no way to retrieve it, effectively rendering the token unusable and potentially causing financial loss to the token owner.
Manual review
To mitigate this vulnerability, the smart contract should be updated to include a check that calls the onERC721Received()
function on the recipient contract during the minting process. If the recipient is a contract, the minting function should only proceed if the call to onERC721Received()
is successful and returns the expected magic value. If the recipient is an externally owned account (EOA), this check can be skipped. The resolution involves implementing a new macro in the Huff code that performs this check and integrating it into the minting logic. If the check fails, the contract should revert the transaction to prevent the token from being locked in an incompatible contract.
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.