The _safemint()
function incorporates the onERC721Received
function, which serves to verify the receiver contract's capability to handle NFTs preventing potential situations where NFTs may become permanently locked. This function is utilized in the safeTransferFrom
and _safeMint
operations of the ERC721 contract.
The vulnerability arises in the selectWinner()
function, which calls _safeMint()
, a function that includes a callback to the "to" address argument. Functions containing callbacks should be equipped with reentrancy guards to protect against potential malicious actors, both internal and external to the protocol.
The _checkOnERC721Received
function responsible for this verification is as follows:
see the _checkOnERC721Received
, which is as follows,
Without a reentrancy guard, the onERC721Received
function could permit an attacker-controlled contract to initiate additional mints, posing a significant security risk.
This vulnerability enables the attacker to perform multiple mints.
Manual code review
It is advisable to integrate a reentrancy modifier from OpenZeppelin or other reputable security libraries to prevent any potential reentrancy attacks. Implementing this safeguard will significantly increase the security and robustness of the protocol, mitigating the risk of unauthorized mints and other associated vulnerabilities.
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.