The graduateAndUpgrade
function in the LevelOne contract incorrectly distributes teacher wages. It calculates the total teacher allocation (35% of the bursary) but then gives this full amount to each teacher instead of dividing it among all teachers. This creates a critical financial vulnerability that results in excessive payouts and potential insolvency of the system.
In the graduateAndUpgrade
function, the contract calculates the teacher payment amount as:
result
This calculates 35% of the bursary, which should be the total allocation for all teachers combined. However, this amount is then distributed to each teacher:
This means each teacher receives the full 35% of the bursary instead of their proportional share (35% divided by the number of teachers).
This vulnerability has severe financial implications:
With 2 teachers: 70% of the bursary is distributed (instead of 35%)
With 3 teachers: 105% of the bursary is distributed (exceeding available funds)
With 4+ teachers: The contract will attempt to transfer more funds than available, causing transactions to fail
This leads to:
Excessive payouts that drain the school's funds
System insolvency when there are 3 or more teachers
Failed upgrades due to insufficient funds for transfers
Violation of the payment structure specified in the requirements (35% for all teachers combined)
The severity is high because:
Direct financial loss to the protocol
Complete breakdown of the economic model
Failure of core functionality (upgrades) as teacher count increases
Manual code review
Foundry testing framework for vulnerability confirmation
Modify the wage distribution logic to properly divide the total teacher allocation among all teachers:
Test for even/odd numbersd abd edge cases.
This ensures that the total payment to all teachers equals exactly 35% of the bursary, regardless of how many teachers are in the system, which aligns with the specified payment structure in the requirements.
`payPerTeacher` in `graduateAndUpgrade()` is incorrectly calculated.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.