Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

Lack of Reentrancy Protection in withdrawEgg

Summar

A malicious contract could exploit a reentrancy vulnerability during NFT withdrawals.

Vulnerability Details

The function performs the external call (NFT transfer) before clearing internal state:

function withdrawEgg(uint256 tokenId) public {
require(storedEggs[tokenId], "Egg not in vault");
require(eggDepositors[tokenId] == msg.sender, "Not the original depositor");
storedEggs[tokenId] = false;
delete eggDepositors[tokenId];
eggNFT.transferFrom(address(this), msg.sender, tokenId); // external call
emit EggWithdrawn(msg.sender, tokenId);
}
  • If msg.sender is a contract, it could re-enter withdrawEgg via a fallback/receiver hook before the state is fully cleared.

Impact

Could allow multiple withdrawals of the same NFT or manipulation of internal state in an unsafe manner.

Tools Used

Manual review

Recommendations

  • Use OpenZeppelin's ReentrancyGuard.

  • Also consider state changes before external calls as an added safeguard

Updates

Lead Judging Commences

m3dython Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.