Hawk High

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

Missing Verification of Four Reviews per Student Permits Premature Graduation

Summary

There is no check for all students have been reviewed 4 times before upgrading to LevelTwoimplementation in the LevelOne::graduateAndUpgradefunction.

Impact

With no check in graduateAndUpgradefunction leads to the possibility to upgrade to new implementaion before all students gets 4 reviews. This break a protocol invariant leading to not intended behavior of the contract.

Tools Used

Manual code review

Recommendations

Add a check in the graduateAndUpgradefunction:

+ error HH_StudentNotReviewed();
function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
+ uint256 totalStudents = listOfStudents.length;
+ for (uint256 n = 0; n < totalStudents; n++) {
+ address student = listOfStudents[n];
+ if (reviewCount[student] < 4) {
+ revert HH_StudentNotReviewed();
+ }
+ }
uint256 totalTeachers = listOfTeachers.length;
uint256 payPerTeacher = (bursary * TEACHER_WAGE) / PRECISION;
uint256 principalPay = (bursary * PRINCIPAL_WAGE) / PRECISION;
_authorizeUpgrade(_levelTwo);
for (uint256 n = 0; n < totalTeachers; n++) {
usdc.safeTransfer(listOfTeachers[n], payPerTeacher);
}
usdc.safeTransfer(principal, principalPay);
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge about 2 months ago
Submission Judgement Published
Validated
Assigned finding tags:

cut-off criteria not applied

All students are graduated when the graduation function is called as the cut-off criteria is not applied.

Support

FAQs

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