Hawk High

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

Missing increment of review counter allows unlimited reviews

Description:

In the giveReview() function, there is a check to ensure that students don't receive more than 4 reviews (one per week), but the counter that tracks the number of reviews is never incremented:

function giveReview(address _student, bool review) public onlyTeacher {
if (!isStudent[_student]) {
revert HH__StudentDoesNotExist();
}
require(reviewCount[_student] < 5, "Student review count exceeded!!!");
require(block.timestamp >= lastReviewTime[_student] + reviewTime, "Reviews can only be given once per week");
// where `false` is a bad review and true is a good review
if (!review) {
studentScore[_student] -= 10;
}
// Update last review time
lastReviewTime[_student] = block.timestamp;
// Missing: reviewCount[_student]++;
emit ReviewGiven(_student, review, studentScore[_student]);
}

According to the documentation, there are strict requirements about reviews:

> Students can only be reviewed once per week

> Students must have gotten all reviews before system upgrade. System upgrade should not occur if any student has not gotten 4 reviews (one for each week)

Impact:

Teachers can give unlimited reviews to students as long as they wait one week between reviews (until the Principal calls graduateAndUpgrade()), potentially reducing student scores to zero through repeated bad reviews.

The system cannot properly enforce the requirement that all students must have exactly 4 reviews before upgrading.

Recommended Mitigation:

Add the missing increment to the `giveReview()` function

Updates

Lead Judging Commences

yeahchibyke Lead Judge 6 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.