Hawk High

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

Student Score Underflow Due to Unchecked Subtraction in giveReview

Summary

The giveReview function deducts 10 points from a student's score for every negative review without validating whether the subtraction would cause the score to drop below zero. This can cause the studentScore to underflow, wrapping around to a very large uint256 value, which may break logic dependent on valid score ranges or graduation conditions.

Vulnerability Details

if (!review) {
studentScore[_student] -= 10;
}

Example Exploit:

  1. A student has a score of 5.

  2. A teacher submits a bad review.

  3. studentScore becomes 2^256 - 5 (due to underflow in uint256).

  4. This gives the student an extremely high score, potentially letting them bypass a cutoff or logic that checks for "top performers."

Impact

  • Integrity Violation: Underflowing studentScore breaks the intended scoring logic.

  • False Graduation: A student with a huge wrapped score could wrongly qualify for benefits (e.g., graduation).

  • Review System Compromise: Undermines the credibility of the review system.

Tools Used

  • Manual Code Review

  • Solidity language semantics (uint256 arithmetic behavior pre-0.8 vs post-0.8)

  • Domain knowledge of smart contract score/trust systems

Recommendations

Fixed Code

This ensures:

  • Scores never drop below zero.

  • Good reviews actually benefit students.

  • Prevents exploit scenarios tied to arithmetic overflows/underflows.

if (!review) {
studentScore[_student] = studentScore[_student] > 10 ? studentScore[_student] - 10 : 0;
} else {
studentScore[_student] += 10;
}
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.