Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Valid

No erc721receiver check in HUFF code

Summary

No erc721receiver check in HUFF code

Vulnerability Details

There's no check in huff code if the nft receiver is smart contract.So minting carry on as succesful

  • Attack contract

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import {ERC721Enumerable, ERC721} from '../lib/openzeppelin-contracts/contracts/token/ERC721/extensions/ERC721Enumerable.sol';
import {HorseStore} from "./HorseStore.sol";
import {IERC721Receiver} from '../lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol';
contract Attacker /* is IERC721Receiver */{
HorseStore public horseStore;
uint256 public horseId;
uint256 public counter=1;
constructor(address _horseAddr) {
horseStore=HorseStore(_horseAddr);
}
function mintHorse(uint256 _value)external{
require(_value!=0,"Value shouldnt be zero!");
for(uint i=0;i<_value;i++){
horseStore.mintHorse();}
}
function feedHorse(uint256 _horseId)external{
horseStore.feedHorse(_horseId);
}
function isHappyHorse(uint256 _horseId) external view returns(bool){
return horseStore.isHappyHorse(_horseId);
}
/* function onERC721Received(
address ,
address ,
uint256 tokenId,
bytes calldata
) external returns (bytes4){
horseId=tokenId;
if(counter>5){
counter++;
}
return IERC721Receiver.onERC721Received.selector;
} */
}

test suit

function testCanContractMintEvenwithoutERC721receiverInterface()public{
//current attack contracts erc721 receiver disabled..
//minting success..
attacker.mintHorse(1);
}

Impact

NFT might stuck in smart contract.

Tools Used

foundry

Recommendations

Implement safeMint function or use huffmate erc721 contract.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Components of ERC721 not properly (or at all) implemented in HUFF

Support

FAQs

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