Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Unlimited Student Reviews Due to Unincremented Review Count in [LevelOne::giveReview](https://github.com/CodeHawks-Contests/2025-05-hawk-high/blob/main/src/LevelOne.sol#L277-L293)

Summary

The giveReview function fails to increment the reviewCount for students, allowing teachers to submit unlimited reviews despite the contract's requirement of a maximum of four reviews per student. Additionally, the system upgrade process does not enforce that all students have received exactly four reviews, violating core protocol rules.

Vulnerability Details

Affected Components:

giveReview Function: The function does not increment the reviewCount after submitting a review.

graduateAndUpgrade Function: Missing validation to ensure all students have exactly four reviews before upgrading.

Unlimited Reviews:

In giveReview, reviewCount[_student] is checked (require(reviewCount[_student] < 5) but never incremented. This allows bypassing the intended four-review limit.

Missing Review Validation During Upgrade:

The graduateAndUpgrade function does not verify if all students have received four reviews.

Impact

  • Unlimited Reviews: Students may receive more than four reviews, skewing scores and allowing unfair graduations.

  • Incomplete Reviews: Upgrades can proceed without all students completing four reviews, violating protocol rules and risking invalid state transitions.

Tools Used

Recommendations

Increment reviewCount in giveReview:

function giveReview(address _student, bool review) public onlyTeacher {
// Existing checks...
reviewCount[_student]++; // Add this line
// Rest of the code...
}

Enforce Four-Review Requirement During Upgrade:

function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
// Check all students have exactly 4 reviews
for (uint256 i = 0; i < listOfStudents.length; i++) {
address student = listOfStudents[i];
require(reviewCount[student] == 4, "Student missing reviews");
}
// Proceed with upgrade...
}

Adjust Review Count Check (Optional):

Clarify the maximum reviews by updating the check to reviewCount[_student] < 4 if the intended limit is four (current logic allows five due to <5).

Updates

Lead Judging Commences

yeahchibyke Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

reviewCount not updated

`reviewCount` for students is not updated after each review session

Support

FAQs

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