_safeMint() should be used rather than _mint() wherever possible
Impact
Eentually it is called ERC721 _mint(). Calling _mint() this way does not ensure that the receiver of the NFT is able to accept them, making possible to lose them.
_safeMint() should be used with as it checks to see if a user can properly accept an NFT and reverts otherwise.
There is no check of the address provided by the mint NFT to make sure owner address receiver implements ERC721Receiver.
Details
_mint() is discouraged in favor of _safeMint() which ensures that the recipient is either an EOA or implements IERC721Receiver.
Both open OpenZeppelin and solmate have versions of this function so that NFTs aren’t lost if they’re minted to contracts that cannot transfer them back out.
Lines of code
https://github.com/PartyDAO/party-contracts-c4/blob/3896577b8f0fa16cba129dc2867aba786b730c1b/contracts/party/PartyGovernanceNFT.sol#L132
Vulnerability details
_safeMint() should be used rather than _mint() wherever possible
Impact
Eentually it is called ERC721
_mint()
. Calling_mint()
this way does not ensure that the receiver of the NFT is able to accept them, making possible to lose them._safeMint()
should be used with as it checks to see if a user can properly accept an NFT and reverts otherwise.There is no check of the address provided by the mint NFT to make sure
owner
address receiver implements ERC721Receiver.Details
_mint()
is discouraged in favor of_safeMint()
which ensures that the recipient is either an EOA or implements IERC721Receiver.Both open OpenZeppelin and solmate have versions of this function so that NFTs aren’t lost if they’re minted to contracts that cannot transfer them back out.
References
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/d4d8d2ed9798cc3383912a23b5e8d5cb602f7d4b/contracts/token/ERC721/ERC721.sol#L271
Github Permalinks
https://github.com/PartyDAO/party-contracts-c4/blob/3896577b8f0fa16cba129dc2867aba786b730c1b/contracts/party/PartyGovernanceNFT.sol#L132
Mitigation
Use
_safeMint()
as suggested by OpenZeppelin or include the check before minting.