The EggVault
contract contains a vulnerability in its depositEgg
function that allows any user to deposit an egg (NFT) into the vault and register themselves as the depositor, even if they do not own the NFT. This occurs because the function does not verify the caller's authority over the NFT, only checking that the NFT has been transferred to the vault. As a result, an attacker can steal eggs by depositing them under their own address after the original owner transfers them to the vault, subsequently allowing the attacker to withdraw the NFTs.
The vulnerability is located in the EggVault.depositEgg
function:
Issue:
The function does not restrict who can call it or verify that the caller (msg.sender
) is the legitimate owner or an authorized party. It accepts a depositor parameter without validation, trusting the caller to provide it.
Exploitation Path:
An owner (eAlice) transfers their NFT to the vault using transferFrom
directly.
An attacker calls depositEgg(tokenId, attacker)
before the legitimate deposit is registered, setting themselves as the eggDepositors[tokenId]
.
The attacker can then call withdrawEgg(tokenId)
to transfer the NFT to themselves, effectively stealing it.
Lack of access control on depositEgg
and reliance on an unverified depositor parameter.
This vulnerability bypasses the intended ownership checks in EggHuntGame::depositEggToVault
, which assumes that EggVault::depositEgg
will only be called by the game contract with the correct depositor.
High
Loss of nft ownership.
Steps:
Steps:
Alice mints and owns tokens 1 and 2.
Alice transfers them to the vault.
The attacker calls depositEgg
to register themselves as the depositor.
The attacker withdraws the NFTs, stealing them from Alice.
Manual Review
Implement access control to ensure only authorized parties(game contract) can call depositEgg
. The preferred solution is to restrict the function to the EggHuntGame contract:
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.