Hawk High

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

Transfer the `payPerTeacher` of all teachers just to the first teacher!

Summary

The loop for in the function `LevelOne::graduateAndUpgrade` not transfer the `payPerTeacher` for all the techer, just to teh first teacher!

Vulnerability Details

1- The attacker enter as the first teacher
2- all the `payPerTeacher` of all teacher transfer to that attacker

Impact

The rest of teachers don't get their pays

Tools Used

FOUNDRY

Recommendations

```diff
function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
uint256 totalTeachers = listOfTeachers.length;
+ uint256 payallTeachers = (bursary * TEACHER_WAGE) / PRECISION;
+ uint256 payPerTeacher = payallTeachers / 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 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

incorrect teacher pay calculation

`payPerTeacher` in `graduateAndUpgrade()` is incorrectly calculated.

Support

FAQs

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

Give us feedback!