A vulnerability exists in the Eggstravaganza game and vault system where the NFT contract is updated after tokens have been minted. If a user attempts to deposit a token from the old contract, the deposit will fail due to a mismatch between the contract the vault is pointing to and the contract where the token was originally minted.
The vulnerability stems from the EggVault contract’s setEggNFT() function, which allows the contract owner to switch the NFT contract that the vault references. After updating the NFT contract, any existing tokens minted from the old contract are no longer valid for deposits into the vault.
The problem arises when a player approves a token for deposit, but the vault points to a new NFT contract where that token ID does not exist, causing the transaction to fail with a ERC721NonexistentToken revert.
This occurs because the depositEggToVault function checks the token's ownership via the current NFT contract. If the token was minted by the previous contract, the vault will fail to recognize it, even though the token exists on the old contract.
Loss of deposit functionality: Users can no longer deposit tokens minted from the old contract once the vault's NFT contract is switched, effectively breaking the intended deposit mechanism.
User frustration: Players attempting to deposit eggs from an old contract after the update will experience failed transactions without clear guidance on why their tokens are rejected.
Vault mismanagement: The vault may hold tokens that cannot be deposited properly, creating inconsistencies between the deposited token data and the state of the vault.
In the above Proof of Concept (PoC), the test attempts to deposit token 20 that was minted from the original NFT contract after the vault's NFT reference is changed to a new contract. Since the token doesn't exist in the new contract, it reverts with the ERC721NonexistentToken error.
Foundry:
-Manual Review:
1) The nft address should be immutable and only set during contract deployment
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.