Hawk High

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

Unchecked Score Underflow in giveReview()

Summary

The giveReview() function deducts 10 points from a students’s score when a bad review is given. However, it does not check whether the student score is at least 10 before doing the subtraction. In solidity versions ≥0.8.0, this will revert automatically due to built-in underflow check.

Impact

  • The function will revert if studentScore[_student] < 10, due to underflow protection in Solidity ≥0.8.0.

  • This may unintentionally prevent teachers from submitting bad reviews for students with low scores.

Tools Used

  • Manual code review

Recommendations

Add a require statement to explicitly validate that the student has enough score to deduct:

if (!review) {
require(studentScore[_student] >= 10, "Score too low to deduct");
studentScore[_student] -= 10;
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!