In the EggHuntGame::searchForEgg function, the return value from the external call to eggNFT::mintEgg is ignored. The function is defined to return a bool, indicating whether the minting was successful. However, this value is not used, and the contract proceeds to update state variables such as eggCounter and eggsFound[msg.sender] regardless of the minting outcome. Ignoring return values from external contract calls can lead to inconsistencies in contract state and potential failure to meet functional expectations.
Proof of Code:
Place the following test into EggHuntGameTest.t.sol.
If eggNFT::mintEgg fails and returns false, the contract will still increment eggCounter and increase the eggsFound count, even though the NFT was not successfully minted. This creates a mismatch between the recorded egg count and the actual minted NFTs, potentially leading to incorrect user balances, broken logic in later parts of the system, or even exploitable conditions if those inconsistencies are used as assumptions elsewhere in the contract.
Foundry
Aderyn
Slither
Always check the return value of external calls that indicate success or failure. In this case, ensure the mintEgg call returns true.
Returns a boolean value that isn't utilized by its caller
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.