Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

Uninitialized State Variable

Summary

The reviewCount state variable in the LevelOne contract is declared but never initialized before being used in the contract logic.

Vulnerability Details

Slither detected that the reviewCount state variable at line 48 of LevelOne.sol is never initialized but is used in the giveReview function (lines 277-293). In Solidity, uninitialized state variables default to zero values (0 for integers, false for booleans, address(0) for addresses, etc.). When contract logic relies on these variables having specific initial values, using them without proper initialization can lead to unexpected behavior.

Impact

Medium. If the contract's logic depends on reviewCount having a specific non-zero initial value, the contract may operate incorrectly from the start. This could lead to logical errors in the review system implementation, potentially affecting user experience, data integrity, or even financial operations if the review system is tied to rewards or penalties.

Tools Used

Slither static analysis tool

Recommendations

  • Initialize the reviewCount variable in the contract's constructor or in the initialize function for upgradeable contracts.

  • Add a check in the giveReview function to ensure reviewCount has a valid value before use.

  • Consider implementing a migration function if this issue exists in a deployed contract to explicitly set the correct value.

Updates

Lead Judging Commences

yeahchibyke Lead Judge
27 days ago
yeahchibyke Lead Judge 16 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
yeahchibyke Lead Judge 16 days ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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