Description: In function LevelOne::graduateAndUpgrade there is no check for the amount of reviews students have at the end of the session, making it able for the protocol to be upgraded even if there are students who do not have all 4 reviews. This is breaking the invariant that is specified in the protocol's documentation.
Impact: The protocol invariant is broken, giving the possibility for the principal to upgrade the protocol even if not all students have 4 reviews.
Proof of Concept: As we can see in the test the graduateAndUpgrade function doesn't revert even if all students have 0 reviews.
Recommended Mitigation: Modify the LevelOne::giveReview and LevelOne::enroll functions to increment and track the total number of students fully reviewed, so that graduateAndUpgrade only needs to check a single counter.
Add a new state variable:
In the giveReview function, increment the reviewCount[_student] and when the student reaches exactly 4 reviews, increment fullyReviewedStudents:
In graduateAndUpgrade, simply check:
In LevelOne::expel, if a student who already had 4 reviews is expelled, decrement fullyReviewedStudents so the counter stays correct:
All students are graduated when the graduation function is called as the cut-off criteria is not applied.
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.