The studentScore in LevelOne.sol can underflow when a student with a score less than 10 receives a bad review (studentScore[_student] -= 10;). This results in the student's score wrapping around to a very large positive number, potentially allowing them to incorrectly meet the cutOffScore and graduate.
In LevelOne.sol#giveReview, when review is false, the student's score is decreased:
studentScore is a uint256 and starts at 100. If a student receives enough bad reviews for their score to drop below 10 (e.g., score is 5), the operation 5 - 10 will cause an underflow, and studentScore[_student] will become type(uint256).max - 4.
Incorrect Student Scores: A student with a very poor performance record could, due to underflow, end up with an extremely high score.
Compromised Graduation Logic: The system relies on studentScore to determine if a student meets the cutOffScore for graduation. An artificially inflated score due to underflow can lead to undeserving students being marked as graduated and potentially moved to LevelTwo. This undermines the academic integrity of the Hawk High system and violates the invariant "Any student who doesn't meet the cutOffScore should not be upgraded".
Manual Review, Logical Analysis.
Ensure that studentScore does not underflow. The score should not go below a defined minimum, typically 0.
Code Modification for LevelOne.sol::giveReview:
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.