Description: The removeTeacher() function in the LevelOne contract contains an unbounded loop that iterates through the entire listOfTeachers array to find and remove a specific teacher. As the number of teachers grows, this operation will consume increasing amounts of gas, potentially exceeding block gas limits.
Impact: If the number of teachers becomes too large, the function will require more gas than the block gas limit allows, making it impossible to remove teachers. This would lock the principal into a state where they cannot manage the teaching staff, breaking a core contract function.
Proof of Concept:
Assume the principal adds 1,000+ teachers to the system.
When attempting to remove a teacher near the end of the array or one that doesn't exist, the loop must iterate through most or all teachers.
Each iteration consumes gas for storage reads and comparisons.
The transaction will fail with an "out of gas" error when the required gas exceeds the block limit (currently ~30M on Ethereum mainnet).
Recommended Mitigation: Replace the array-based storage of teachers with a mapping-based approach and a separate array for enumeration. Implement a mechanism to track the index of each teacher in the array:
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.