The depositEggToVault
function in the EggHuntGame
contract attempts to transfer NFTs from users to the vault without checking if the contract has the required approval. This causes transactions to revert when users call the function without previously approving the game contract, making the core deposit functionality unusable for most users.
In the EggHuntGame
contract, the depositEggToVault
function tries to transfer an NFT from the user to the vault:
The code correctly checks that the caller owns the NFT but doesn't verify that they've approved the contract to transfer it. There's even a comment noting "The player must first approve the transfer on the NFT contract", but the code doesn't handle this requirement or provide any helpful error messages to users.
When a user calls this function without first approving the game contract to transfer their NFT, the transaction will revert with an error like ERC721InsufficientApproval
, which is confusing for users who expect the game to handle the deposit process seamlessly.
This vulnerability breaks a core piece of functionality in the game:
Users cannot deposit eggs to the vault using the provided function unless they manually approve the contract first
This creates a poor user experience and may lead to confusion and support issues
Players who don't understand the need for approval may think the game is broken
The issue affects 100% of deposit attempts where approval hasn't been granted
While this doesn't directly lead to fund loss, it severely impacts the usability of a core game function, potentially leading to player abandonment and rendering the vault feature unusable for most users.
Manual code review
Foundry for testing contract interactions
Step 1: Frontend should call this first, then call depositEggToVault after approval
Step 2: After approval is granted -> depositEggToVault => The player must first approve the transfer on the NFT contract
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.