The EggVault
contract contains an authorization vulnerability in the depositEgg()
function. This function lacks proper access control mechanisms to restrict who can call it, allowing any external account to manipulate the deposit records. This vulnerability can lead to incorrect attribution of egg deposits and potentially enable unauthorized withdrawals of NFT assets from the vault.
The vulnerable function is found in the EggVault
contract:
The function is declared with public
visibility and accepts a depositor address as an input parameter and it lacks any validation of the caller's identity. While the function checks that the NFT has been transferred to the vault and that it hasn't already been recorded as deposited, it fails to verify whether the caller is authorized to register deposits. This could permit a malicious actor to specify a different address as the depositor.
The intended architecture appears to be that only the EggHuntGame
contract should call this function, but there is no enforcement of this requirement in the code.
This vulnerability has severe consequences:
Asset Theft: An attacker can hijack NFTs that are already transferred to the vault but not yet registered by calling depositEgg()
with their own address as the depositor.
Deposit Manipulation: Even when deposits are properly recorded, if an NFT is withdrawn and later transferred back to the vault, anyone can call depositEgg()
to register themselves as the depositor.
System Trust: This breaks the trust model of the entire system, as ownership records can be manipulated by any party.
Manual code review
To address this vulnerability, implement proper access control for the depositEgg()
function:
Add Authorized Caller Check:
Design a Secure Deposit Flow:
Consider implementing a single-transaction deposit pattern where the game contract handles both the NFT transfer and deposit registration.
Add Ownership Verification:
Before registering a deposit, verify that the depositor was the previous owner of the NFT by checking the transfer event logs or implementing a custom transfer tracker.
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.