Hawk High

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

bursary storage variable value is not updated upon graduation which could lead to wrong calculations affecting funds-related operations.

Summary

The bursary is a storage variable that gets updated upon each student enrollment. However, this variable is not being updated to match the value of 60% of its' original value upon the graduation.

Vulnerability Details

The developer can make a mistake during working on new function implementation and use the assumed-60% bursary value in his new calculation when it actually has not been updated and remained as the original value.

Impact

  • Loos of funds in the case of functions who are not well tested.

  • Misleading value of bursary being reflected in our LevelTwo implementation.

Tools Used

Manual source code review.

Recommendations

Update the bursary value inside of the graduateAndUpgrade function to match the expected 60% value:

function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
uint256 totalTeachers = listOfTeachers.length;
uint256 payPerTeacher = (bursary * TEACHER_WAGE) / PRECISION;
uint256 principalPay = (bursary * PRINCIPAL_WAGE) / PRECISION;
_authorizeUpgrade(_levelTwo); // used to authorize who can upgrade the contract, you have to pass the new implementation address to it
for (uint256 n = 0; n < totalTeachers; n++) {
usdc.safeTransfer(listOfTeachers[n], payPerTeacher); // pay the teachers
}
usdc.safeTransfer(principal, principalPay); // pay the principal
bursary = (bursary * 60) / PRECISION; // update the bursary value to match 60% of the original value
}
Updates

Lead Judging Commences

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

bursary not updated

The bursary is not updated after wages have been paid in `graduateAndUpgrade()` function

Support

FAQs

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