The removeTeacher() and expel() functions in LevelOne.sol use a swap-and-pop pattern for array element removal that only removes the first occurrence of an address. If duplicate entries exist in the arrays (through storage manipulation or other vulnerabilities), the functions will leave "ghost entries" while updating the mapping to indicate removal, creating an inconsistent contract state.
In removeTeacher() (lines 229-238):
Similarly in expel() (lines 255-264):
The break statement causes the loop to exit after finding the first occurrence, leaving any duplicate entries in the array while marking the address as removed in the mapping.
State Inconsistency: Arrays may contain addresses marked as non-teachers/non-students in mappings
Broken Access Control: Functions relying on array iteration may grant access to removed users
UI/Integration Issues: Off-chain systems relying on array data will show incorrect information
Potential Reentrancy Vectors: Ghost entries could be exploited in complex attack scenarios
Manual code review
Foundry forge
Replace the current removal logic with a comprehensive approach that removes all instances:
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.