Summary
mintRapper
allows rapper to mint unlimited tokens
Impact
The discrepancy between allowing unlimited NFT minting by the owner and the documented behavior of users being able to mint only one NFT introduces a high impact, potentially leading to centralization and disruption of intended distribution.
PoC
function testMintUnlimitedRappers() public {
address testUser = makeAddr("Bob");
vm.prank(testUser);
oneShot.mintRapper();
console.log(oneShot.getNextTokenId());
vm.prank(testUser);
oneShot.mintRapper();
console.log(oneShot.getNextTokenId());
vm.prank(testUser);
oneShot.mintRapper();
console.log(oneShot.getNextTokenId());
}
Result:
[PASS] testMintUnlimitedRappers() (gas: 212714)
Logs:
1
2
3
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.64ms
Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
Recommendations
Add a check which doesn't allow rapper to mint more than one NFT.
For example:
mapping(address => bool) public hasMintedRapper;
function mintRapper() public {
require(!hasMintedRapper[msg.sender], "You can only mint one rapper.");
uint256 tokenId = _nextTokenId++;
_safeMint(msg.sender, tokenId);
rapperStats[tokenId] = RapperStats({
weakKnees: true,
heavyArms: true,
spaghettiSweater: true,
calmAndReady: false,
battlesWon: 0
});
hasMintedRapper[msg.sender] = true;
}