The giveReview function in the LevelOne contract contains a critical oversight: while it checks if a student has received fewer than 5 reviews, it never increments the reviewCount mapping after performing a review. This allows teachers to perform an unlimited number of reviews for the same student (subject only to the weekly time limitation), bypassing the intended limit of 4 reviews per student.
In the giveReview function, the contract checks reviewCount[_student] < 5 to ensure a student hasn't received too many reviews:
The issue is that while the function checks if the review count exceeds the limit, it never increments reviewCount[_student] after performing the review. As a result, the check will always pass as long as the weekly time limitation between reviews is respected.
A student can receive an unlimited number of reviews instead of the intended maximum of 5
Teachers can repeatedly give negative reviews to the same student, potentially reducing their score to an extremely low value
This could be used maliciously by teachers to prevent certain students from graduating by repeatedly giving negative reviews
The business logic of having a maximum review limit is entirely bypassed
Manual code review
Custom test case to demonstrate the vulnerability
Add the following test to your test file to demonstrate the issue:
Modify the giveReview function to increment the review count after each review:
Additionally, consider adding a function to view a student's current review count for transparency.
`reviewCount` for students is not updated after each review session
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.