Hawk High

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

Misaccounted bursary Balance After graduateAndUpgrade() Function Execution

Summary

The graduateAndUpgrade function is intended to allocate 35% of the bursary to teachers, 5% to the principal and retain the remaining 60% in the bursary for future use. However while the USDC transfers of teachers and principal are executed, the bursary variable is not updated to reflect these payouts.

Impact

  • The bursary retains its full value even after 40% has been disbursed.

  • Any logic relying on bursary will operate on an inflated and inaccurate balance.

  • This could lead to double-spending or misallocation of already disbursed funds.

Proof Of Concept

Assume:

bursary = 1000e18;
TEACHER_WAGE = 3500; // Represents 35% with PRECISION = 10000
PRINCIPAL_WAGE = 500; // Represents 5%

On calling graduateAndUpgrade():

  • Teachers receive 350e18 in total.

  • Principal receives 50e18.

Expected outcome:

bursary == 600e18;

Actual outcome:

bursary == 1000e18; // Incorrect – no deduction

This leaves 400e18 unaccounted for, which could be inadvertently reused.

Tools Used

  • Manual code review

Solution

Subtract the 40% of the distributed wages from the bursary

uint256 totalPaidOut = teacherShare + principalShare;
bursary -= totalPaidOut;

This way:

  • bursary is updated to reflect the actual remaining balance (60%) after the payout

  • All future logic using bursary will be based on actual amount

Recommendations

Add the following code to graduateAndUpgrade function

uint256 teacherShare = (bursary * TEACHER_WAGE) / PRECISION;
uint256 principalShare = (bursary * PRINCIPAL_WAGE) / PRECISION;
uint256 totalPaidOut = teacherShare + principalShare;
// Distribute payments...
bursary -= totalPaidOut;
Updates

Lead Judging Commences

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

Give us feedback!