Hawk High

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

Unfair Payout logic in (graduateAndUpgrade) function

Summary

There is an unfair payout logic in graduateAndUpgrade function where the pyout share for teacher can exceed the total amount of bursary itself.

Vulnerability Details

In the graduateAndUpgrade function the logic behind payment share is calculated in a way that it may even exceed the total amount of bursary in the contract. The code below has flaw in its logic:

uint256 payPerTeacher = (bursary * TEACHER_WAGE) / PRECISION;

According to the above code line let's assume Total Bursary amount is 1000usdc and there are 3 teachers to be paid than according to the code

1000 * 35 = 35000 / 100 = 350. And to be paid to 3 teachers 350 * 3 = 1050 which exceeds the total bursary amount itself.

Impact

This flaw in the code can pay the teachers the amount that they are not suppose to recieve and may even drain all the amount in the contract itself to one teacher itself.

Tools Used

Manual Testing

Recommendations

Instead of that we can add the following line of code:

uint256 totalTeacherWages = (bursary * TEACHER_WAGE) / PRECISION;
uint256 payPerTeacher = totalTeacherWages / totalTeachers;
Updates

Lead Judging Commences

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

incorrect teacher pay calculation

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

yeahchibyke Lead Judge 3 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.