TheEggVault::depositEgg
function in the EggVault
contract is publicly accessible, allowing any address to register themselves as the depositor of an NFT that has been transferred to the vault. This could lead to unauthorized claims of ownership over deposited eggs.
The function only checks if:
The NFT is owned by the vault.
The egg hasn't been deposited before.
Alice legitimately obtains an NFT (tokenId: 50) through the game.
Alice transfers her NFT to theEggVault
contract (before officially registering it).
Bob (the attacker) sees this transaction and front-runs Alice's deposit call.
Bob calls EggVauldt::depositEgg(50, bob)
, registering himself as the depositor.
Alice can no longer withdraw her NFT because the system thinks Bob is the depositor.
Bob can now withdraw Alice's NFT using the withdrawEgg function.
Any address can claim ownership of deposited NFTs.
Original owners could lose their ability to withdraw their eggs.
Malicious actors could steal deposited eggs by registering themselves as depositors.
Breaks the trust model of the vault system.
Manual review
To fix this issue:
Change EggVault::depositEgg
to beexternal
instead of public
.
Add authorization to ensure only the EggHuntGame
contract can call EggVault::depositEgg
.
Updated function:
Front-running depositEgg allows deposit ownership hijacking.
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.