In the LevelOne::giveReview function, a conditional decreases the LevelOne::studentScore if a bad review is submitted. However, there is no corresponding logic for a good review, which reduces code clarity and readability and may introduce issues in the future.
If a teacher submits a bad review in the LevelOne::giveReview function, the student's LevelOne::studentScore decreases by 10 points. However, if a good review is submitted, no changes are made to the score. This behavior makes the protocol's intention unclear and could lead to potential vulnerabilities in the contract.
This issue may disrupt the system if good reviews are not handled as expected. While it might make sense for a good review to leave the score unchanged, the contract does not explicitly document this behavior. This could be problematic, especially if LevelOne::cutOffScore is ever set above the initial score (100), making impossible for students to improve its initial socre.
The issue can be reproduced by adding the following code to the LevelOneAngGraduateTest.t.sol contract, which demonstrates that the student's score remains at the initial value (100) after a good review:
Teacher alice submits a good review for student fin.
The value of studentScore(fin) remains unchanged, as confirmed in the console output.
The issue was identified through manual review.
1. Add NatSpec comments before the function to clearly document the intended behavior:
2. Optionally, add an else clause in LevelOne::giveReview function for better readability and clarity of intention. Two options are presented:
The first one does not modify the studentScore[_student] value when a positive review is submitted. If this behavior is intentional, no change is needed.
The second option increases the studentScore[_student] value by ten upon receiving a positive review.
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.