Eggstravaganza

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

Unchecked Return in `EggHuntGame::searchForEgg()`

Description:
The searchForEgg() function in the EggHuntGame contract calls eggNFT.mintEgg() without checking its return value. This could lead to logical inconsistencies if the minting process fails silently.

Impact:

  1. If mintEgg() fails but does not revert, the contract will assume the minting was successful, leading to incorrect state updates.

  2. The EggFound event will be emitted even if minting fails, creating false positives and potential abuse scenarios.

  3. Silent failures could result in undetected issues, compromising the integrity of the contract.

Proof of Concept:

function searchForEgg() external {
...
if (random < eggFindThreshold) {
eggCounter++;
eggsFound[msg.sender] += 1;
eggNFT.mintEgg(msg.sender, eggCounter); // Return value not checked
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}
}

Recommended Mitigation:
Check the return value of mintEgg() and ensure it succeeds before proceeding with state updates or emitting events. For example:

function searchForEgg() external {
...
if (random < eggFindThreshold) {
eggCounter++;
eggsFound[msg.sender] += 1;
bool success = eggNFT.mintEgg(msg.sender, eggCounter);
require(success, "Egg minting failed");
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}
}

This ensures that the contract handles minting failures gracefully and maintains a consistent state.

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!