Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: high
Invalid

Lack of `IERC721Receiver ` implementation on BuyerAgent, leading to Potentially Locked NFTs.

Vulnerability Details

  • In the BuyerAgent.sol contract, the buyer agent receives NFTs via the purchase() function. However, the BuyerAgent contract does not implement the IERC721Receiver interface, which is required for contracts that receive ERC721 tokens (NFTs).

  • When an NFT is transferred to a contract that does not implement the IERC721Receiver interface, the transfer may succeed, but the NFT could become inaccessible or permanently locked within the contract. This is because ERC721 tokens require contracts to implement the onERC721Received() function to safely handle incoming NFT transfers.

Impact

  • Locked NFTs: NFTs transferred to the BuyerAgent contract may become permanently inaccessible if the contract does not implement IERC721Receiver. This could result in assets being locked within the contract with no way to recover or transfer them.

  • Non-Standard Behavior: The lack of IERC721Receiver implementation violates standard ERC721 practices, which expect receiving contracts to implement this interface

Tools Used

  • Manual review

Recommendations

  • Implement IERC721Receiver Interface on BuyerAgent contract : The BuyerAgent contract should implement the IERC721Receiver interface to ensure that it can safely receive and manage NFTs. This includes implementing the onERC721Received() function.

import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
contract BuyerAgent is IERC721Receiver {
// Implement onERC721Received to handle incoming NFT transfers
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external override returns (bytes4) {
// Handle NFT reception logic here (e.g., store tokenId)
return this.onERC721Received.selector;
}
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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