Description:
EggstravaganzaNFT owner can set a new gameContract through EggstravaganzaNFT::setGameContract. The old gameContract will no longer be able to mint NFTs due to the check in EggstravaganzaNFT::mintEgg that checks whether the minter is the newly set gameContract.
If the old gameContract has minted more NFTs than the new one (its tokenId is bigger), then the new gameContract won't be able to mint new NFTs because the supplied tokenId would already have been minted.
Impact:
Users that have successfully found an egg with both the old and the new EggHuntGame contract cannot mint it, thus not providing them with their rightful acquisition.
Proof of Concept:
User gets an egg from the game.
The nft owner changes the gameContract address to a new one with no minted eggs.
Users from both games that win eggs cannot mint them.
Proof of Code:
Create a new EggHuntGame contract and set it up in EggHuntGameTest.t.sol and place the following test in the same file.
Recommended Mitigation:
Have a mapping of allowed EggHuntGames that can mint NFTs in the EggstravaganzaNFT::mintEgg function and use its totalSupply to keep track of tokenIds instead of EggHuntGame::eggCounter variable.
Or use openzeppelin's access control for authorization.
Changing the NFT contract address doesn't update the storedEggs and eggDepositors mappings
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.