Eggstravaganza

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

Reentrancy Risk in Deposit `EggVault`

Description:
The depositEgg() function in the EggVault contract performs state changes after an external call to the ownerOf function of the eggNFT contract. This introduces a reentrancy risk, as malicious contracts could exploit this sequence to manipulate the state of the vault.

Impact:
High - Reentrancy attacks could lead to unauthorized state changes, such as incorrect egg deposits or withdrawals, compromising the integrity of the vault.

Proof of Concept:

function depositEgg(uint256 tokenId) external {
require(eggNFT.ownerOf(tokenId) == msg.sender, "Not the owner"); // External call
storedEggs[tokenId] = true; // State change after external call
}

Recommended Mitigation:
Reorder the operations in the depositEgg() function to perform state changes before making external calls. For example:

function depositEgg(uint256 tokenId, address depositor) public {
storedEggs[tokenId] = true; // State first
eggDepositors[tokenId] = depositor;
require(eggNFT.ownerOf(tokenId) == address(this)); // Check after
emit EggDeposited(depositor, tokenId);
}
Updates

Lead Judging Commences

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

Support

FAQs

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

Give us feedback!