The EggVault::setEggNFT
function allows the owner to change the NFT contract address without any restrictions, even when there are active deposits. This can result in users permanently losing access to their deposited NFTs, as the vault will attempt to interact with the new NFT contract address which has no knowledge of the previously deposited tokens.
The vulnerability exists in the EggVault::setEggNFT
function:
The function only checks that the new address is not zero but fails to:
Check if there are any active deposits in the vault
Implement any time-delay or notification mechanism for users
Have any mechanism to migrate existing deposits
When the NFT contract address is changed:
The vault still holds the original NFTs
The vault's state (storedEggs
and eggDepositors
mappings) remains unchanged
All withdrawal attempts fail because the new NFT contract has no knowledge of the original tokens
This creates a permanent lock of user funds as:
The new NFT contract will revert on transferFrom
calls for non-existent tokens
The original NFT contract is no longer referenced by the vault
There is no mechanism to recover or migrate the locked tokens
Add this test file EggVaultUpgradeTest.t
:
Run forge test --match-contract "EggVaultUpgradeTest" -vvv
:
High severity due to permanent loss of user funds
No recovery mechanism available
Affects all users with active deposits when the NFT address is changed
Could be exploited maliciously or triggered accidentally by admin
Short term:
Add a check for active deposits before allowing NFT address changes:
Long term:
Implement an upgradeable pattern that includes:
Time-delay for critical parameter changes
User notification mechanism
Emergency withdrawal functionality
Consider implementing a token migration mechanism if NFT contract updates are necessary
Add events for important state changes to improve transparency
Consider making the NFT address immutable after initial setup
Owner is trusted and is not expected to interact in ways that would compromise security
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.