Description:
The mintProfile function in the SoulboundProfileNFT contract is vulnerable to a reentrancy attack. This Attack vector possible because the function calls _safeMint, which invokes an external call to onERC721Received before updating the contract’s state variables (SoulboundProfileNFT::profileToToken). This violates the Checks-Effects-Interactions (CEI) pattern, allowing an attacker to re-enter the contract and mint multiple NFTs for the same address.
Impact: An attacker can exploit this vulnerability to mint unlimited soulbound NFTs from one malicious contract, which breaks the intended one-profile-per-user restriction.
Proof of Concept:
Add this Interface and Contract to testSoulboundProfileNFT.t.sol
after that, add this test function to testSoulboundProfileNFT.t.sol
Recommended Mitigation:
To prevent reentrancy, apply the Checks-Effects-Interactions(CEI) pattern by updating the contract’s state variables before calling _safeMint.
Additionally, consider using the ReentrancyGuard modifier from OpenZeppelin to add an extra layer of security against reentrancy attacks.
Likelihood: High, anyone can do it. Impact: Low, several profile will be minted, which is not allowed by the protocol, but only the last one will be stored in profileToToken and won't affect `likeUser` or `matchRewards`.
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.