Game owner calling EggVault::setEggNFT
to set new egg NFT address will overwrite EggVault::eggNFT
with the new egg NFT address. Function call EggHuntGame::depositEggToVault
will pass execution flow to EggVault::depositEgg
which evaluates eggNFT.ownerOf
on the new egg NFT instead of the old egg NFT, which does not exist and will revert with ERC721NonexistentToken(<tokenId>)
. Hence, players are unable to deposit eggs into the vault through EggHuntGame::depositEggToVault
, breaking core protocol functionality.
After game owner calls EggVault::setEggNFT
to set new egg NFT address, the NFT address state variable EggVault::eggNFT
will be overwritten with the new egg NFT address. As such, any function calls involving EggVault::eggNFT
will be executed in the context of the new egg NFT instead of the old egg NFT.
In particular, when a player attempts to deposit an egg into the vault by calling EggHuntGame::depositEggToVault
, the execution flow is passed to EggVault::depositEgg
on #L88
. Subsequently, the require
statement on EggHuntGame::depositEggToVault#L88
will attempt to evaluate eggNFT.ownerOf
on the new egg NFT instead of the old egg NFT. However, the NFT does not exist, hence, the call will revert with ERC721NonexistentToken(<tokenId>)
.
EggHuntGame::depositEggToVault#L88
Impact: Medium, players will to be unable to deposit eggs into vault through EggHuntGame::depositEggToVault
, disrupting the core protocol functionality
Likelihood: Low, game owner is trusted
Severity: Medium
Place the following code into EggHuntGameTest.t.sol
and run using:
forge test --mt testSetEggNFTBreaksDepositToVault
Manual review
Consider removing the EggVault::setEggNFT
function
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.