Hawk High

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

`LevelOne::giveReview()` does not increment `reviewCount`, breaking evaluation logic

Description:

The giveReview() function does not increment the reviewCount[_student] counter. Despite having a condition that checks if the maximum number of reviews has been reached, the lack of incrementing this counter means the condition is never met, and thus the number of allowed reviews is not limited.

This inconsistency prevents proper validation based on the number of reviews, breaking the system's functional requirements.

Impact:

  • Students can continue receiving reviews without a practical limit, as the counter is not incremented and the cutoff condition is never met.

  • It is impossible to verify if they have been fully evaluated.

  • Promotion is blocked, as the system relies on this counter to validate whether a student has completed their evaluation cycle.

Proof of Concept:

This test demonstrates that a student can receive up to 7 reviews because the reviewCount counter is not incremented within giveReview().

function test_reviewCount() public {
for (uint256 i; i < 7; i++) {
vm.warp(block.timestamp + (i + 1) * 1 weeks);
vm.prank(alice);
LevelOne(proxy).giveReview(clara, true);
}
}
[PASS] test_reviewCount() (gas: 3839780)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 7.05ms (2.57ms CPU time)

Recommende Mitigation:

Add the following line inside giveReview():

function giveReview(address _student, bool review) public onlyTeacher {
...
if (!review) {
studentScore[_student] -= 10;
}
// Update last review time
lastReviewTime[_student] = block.timestamp;
+ reviewCount[_student] += 1;
emit ReviewGiven(_student, review, studentScore[_student]);
}
Updates

Lead Judging Commences

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