Description:
In EggVault::setEggNFT the vault owner can set a new eggNFT contract address. Players that still have egg NFTs in the old eggNFT contract won't be able to deposit them through neither EggVault::depositEgg nor EggHuntGame::depositEggToVault or withdraw their egg NFT(s) throught EggVault::withdrawEgg.
Impact:
Players won't be able to deposit or withdraw their egg NFT(s). The deposited egg NFT(s) could be stuck until the owner changes the eggNFT address back the old eggNFT contract.
Proof of Concept:
User gets an egg from the game.
The vault owner changes the eggNFT address.
User tries to deposit the egg, but can't.
User gets an egg and deposits it into the vault.
The vault owner changes the eggNFT address.
User tries to withdraw his egg NFT, but can't.
Proof of Code:
Set up a new EggstravaganzaNFT contract and place the following tests in EggHuntGameTest.t.sol
Recommended Mitigation:
There are several ways to handle this.1
Have a storage variable that keeps track of the number of deposited eggs and EggVault::setEggNFT only allows to change the eggNFT address if that variable is 0. Note that a malicious user might never withdraw their egg and the eggNFT address wouldn't be able to change.
Store NFT addresses in a mapping and only add to the mapping in EggVault::setEggNFT for backwards compatibility. In the EggVault::depositEgg and EggVault::withdrawEgg have the NFT contract address as a parameter. That way when users tries to deposit or withdraw their egg NFT, they vault will deposit or transfer it from the correct eggNFT.
Option #2 but use openzeppelin's access control to check for supported NFTs.
Changing the NFT contract address doesn't update the storedEggs and eggDepositors mappings
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.