Description:
The EggVault contract exposes a critical vulnerability due to the lack of proper access control in the depositEgg() function. If a user transfers an NFT directly to the EggVault contract (e.g. via safeTransferFrom) without using the intended entrypoint EggHuntGame::depositEggToVault(), a front-running vector is opened.
A malicious actor or bot can monitor the mempool for incoming NFT transfers to the vault and immediately front-run a transaction to call EggVault::depositEgg(tokenId, attackerAddress), effectively claiming ownership of the NFT. This enables them to subsequently withdraw the NFT to their own wallet using withdrawEgg().
Since depositEgg() is declared as public and lacks any authorization modifier, any address can call it, regardless of whether they are the rightful depositor.
Impact:
If users strictly use the EggHuntGame::depositEggToVault() function, the attack vector is avoided. However, due to human error or misunderstanding of the intended flow, users may send NFTs manually, exposing themselves to this exploit. The result is the loss of NFTs, as attackers can steal assets in transit by spoofing deposit actions.
Proof of Concept:
Recommended Mitigation:
Restrict access to the depositEgg() function by using a modifier that only allows the trusted EggHuntGame contract to invoke it. For example:
and then add it to the Fn:
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.