The graduateAndUpgrade function in LevelOne.sol does not verify whether the school session has ended (block.timestamp >= sessionEnd), allowing the principal to upgrade the system before the 4-week session is complete, violating the project's invariant.
According to the project invariants, the system upgrade cannot take place unless the school's sessionEnd timestamp has been reached (i.e., after 4 weeks). However, the graduateAndUpgrade function lacks a check for block.timestamp >= sessionEnd. This allows the principal to call the function at any time during the session, triggering an early upgrade and distributing wages prematurely.
Relevant code in graduateAndUpgrade:
No condition ensures that block.timestamp >= sessionEnd, violating the invariant.
Impact: High
An early upgrade severely disrupts protocol functionality by allowing the system to transition to LevelTwo before students complete their 4 weekly reviews. This can result in unfair graduation outcomes, premature wage distribution, and violation of the project's core logic. While no direct fund loss occurs, the protocol's integrity and fairness are significantly compromised.
Likelihood: Medium
Exploitation requires the principal to intentionally or mistakenly call graduateAndUpgrade early. While this is not guaranteed, it is feasible, especially if the principal's account is compromised or the function is called in error.
Manual code analysis
Add a check to ensure the session has ended before allowing the upgrade. Suggested code modification:
This ensures the upgrade adheres to the 4-week session invariant.
`graduateAndUpgrade()` can be called successfully even when the school session has not ended
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.