The depositEgg
function allows any caller to specify the depositor
address for a given tokenId
. This introduces a critical vulnerability where a malicious actor can frontrun the legitimate depositor by calling depositEgg
with themselves as the depositor
after the victim transfers the NFT to the vault but before the victim records the deposit. Once registered, the attacker gains control over the egg’s withdrawal process, effectively stealing the NFT.
This behavior breaks user expectations and can result in ithe rreversible loss of NFTs, especially since the vault is assumed to be a trusted custodian.
High: Unauthorized withdrawal of NFTs.
Attackers can steal NFTs from legitimate owners by racing them to call depositEgg
.
Original owners are unable to reclaim their NFTs once the attacker has withdrawn them.
Damages user trust and can lead to asset loss if exploited in a live environment.
Option 1: Infer the depositor from msg.sender
inside depositEgg()
Instead of allowing the caller to specify a depositor, the contract should infer it from the transaction sender. This prevents unauthorized users from claiming others’ NFTs.
Option 2: Implement onERC721Received
to automate deposits via safeTransferFrom
By implementing the onERC721Received
interface, the vault can automatically register a deposit when an NFT is safely transferred, using the from
field to capture the actual depositor. This eliminates the need for a manual depositEgg()
call and prevents front-running entirely.
This method is highly user-friendly and front-running resistant, making it ideal for integrating secure and seamless NFT deposits into the vault.
Recommended Approach:
Use onERC721Received
as the primary deposit method and optionally retain a simplified version of depositEgg()
that infers the depositor from msg.sender
for compatibility with direct transferFrom
calls. This ensures both safety and ease of use across different user behaviors.
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.