Description: The graduateAndUpgrade() function in the LevelOne contract contains an unbounded loop that iterates through all teachers to distribute payments. As the number of teachers increases, this function will consume more gas and can eventually exceed block gas limits, preventing successful execution of the graduation and upgrade process.
Code Snippet:
Impact: If the number of teachers grows too large, the contract will be unable to complete the graduation and upgrade process. This prevents the contract from upgrading to a new implementation and distributing payments to teachers and the principal, effectively locking funds in the contract and halting the progression of the school system.
Proof of Concept:
The principal adds a large number of teachers (100+).
When attempting to call graduateAndUpgrade(), each teacher receives a payment via safeTransfer().
Each transfer consumes significant gas (~21,000 base + ~5,000 for the ERC20 transfer).
With enough teachers, the total gas required will exceed the block gas limit (~30M on Ethereum).
The transaction will fail with an "out of gas" error, preventing the upgrade.
Recommended Mitigation: Implement a batch processing pattern to distribute payments across multiple transactions:
Due to the use of a push system as regards payment of teacher wages, there is a risk of possible DoS as gas costs increase in direct proportion to size of teachers list.
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.