Hawk High

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

Each teacher shares 35% of bursary

Summary

If 3 teachers, they will get 3 × 35% = 105% of bursary!

Vulnerability Details

If usdc contract's

safeTransfer calls the token's transfer() function.

If transfer() returns false or reverts, then safeTransfer reverts the entire transaction.

So if at any point there’s not enough balance to transfer to the next teacher:

  • That call to safeTransfer(...) will revert

  • The entire loop and transaction will revert

No funds will be transferred at all (even to the first few teachers)

Impact

If the balance of the usdc contract is greater than totalTeachers * payPerTeacher, an amount of funds 35 * totalTeachers% will be shared, which will have a serious impact on management.

On the other hand, if the balance is insufficient, the safeTransfer function will fail and no teacher will receive money, and causing no one to teach.

Tools Used

Manual Review

Recommendations

Calculate each teacher's allocation:
payPerTeacher = payTotalTeacher / totalTeachers.

uint256 payTotalTeacher = (bursary * TEACHER_WAGE) / PRECISION;
uint256 payPerTeacher = totalTeacher > 0 ? payTotalTeacher / totalTeachers : 0;
Updates

Lead Judging Commences

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