Hawk High

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

Teachers allowed to give reviews even after the school session has ended.

Summary

Teachers allowed to give reviews even after the school session has ended.

Vulnerability Details

Since there is no require statement preventing reviews from being given after the session has ended, a teacher would still be allowed to give a review as long as it is still under the count limit of 5 (the project description implies there should be a max of 4 reviews able to be given since it only allowes 1 per week and each session should run only 4 weeks, but the code currently allows for 5 which is another separate bug).

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;
emit ReviewGiven(_student, review, studentScore[_student]);
}

Impact

If the system is already upgraded and a student is already graduated, it should have no impact. If a student is still enrolled though and the principal hasn't called 'graduateAndUpgrade()' successfully yet, this would allow for the student's score to be altered, potentially changing them from a failing grade to a passing or vice versa.

Tools Used

Manual review and Foundry

Recommendations

Include a revert that prevents reviews from being added after session end:

function giveReview(address _student, bool review) public onlyTeacher {
if (!isStudent[_student]) {
revert HH__StudentDoesNotExist();
}
+ if (inSession == false) {
+ revert HH__NotAllowed();
+ }
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;
emit ReviewGiven(_student, review, studentScore[_student]);
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

session state not updated

`inSession` not updated after during upgrade

Support

FAQs

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