Hawk High

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

LevelOne::graduateAndUpgrade function lacks the session over check

Summary

LevelOne::graduateAndUpgrade function lacks the session over check.Principal can call graduateAndUpgrade before the session end,conflicting with the readme.md:At the end of the school session (4 weeks), the system is upgraded to a new one.

Vulnerability Details

The session can be graduateAndUpgrade any time instead of 4 weeks.

function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
@> //@audit this function should be called only when the session is over
// notYetInSession is needed
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
uint256 totalTeachers = listOfTeachers.length;
//@audit the share is not right
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);
}

Tools Used

foundry

Recommendations


function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
//session should has been started
+ if (inSession == false) {
+ revert();
+ }
//check the time 4 weeks
+ if (sessionEnd >= block.timestamp){
+ revert();
+ }
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
uint256 totalTeachers = listOfTeachers.length;
//@audit the share is not right
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 19 days ago
Submission Judgement Published
Validated
Assigned finding tags:

can graduate without session end

`graduateAndUpgrade()` can be called successfully even when the school session has not ended

yeahchibyke Lead Judge 19 days ago
Submission Judgement Published
Validated
Assigned finding tags:

can graduate without session end

`graduateAndUpgrade()` can be called successfully even when the school session has not ended

Support

FAQs

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