Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Missing session completion verification

Summary

In the LevelOne contract, the graduateAndUpgrade function is designed to handle the graduation process and upgrade the contract to a new implementation. However, the function does not include a check to confirm that the current session has ended (block.timestamp >= sessionEnd) before proceeding. This allows the principal to initiate graduation and contract upgrades at any time, regardless of the session's status.

Vulnerability Details

Missing Session Completion Verification
Issue: The function lacks a condition to verify that the session has concluded.

Implication: Graduation and contract upgrades can occur prematurely, potentially disrupting the intended academic cycle and leading to inconsistencies in student evaluations.

function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
uint256 totalTeachers = listOfTeachers.length;
uint256 payPerTeacher = (bursary * TEACHER_WAGE) / PRECISION;
uint256 principalPay = (bursary * PRINCIPAL_WAGE) / PRECISION;
_authorizeUpgrade(_levelTwo);
for (uint256 n = 0; n < totalTeachers; n++) {
usdc.safeTransfer(listOfTeachers[n], payPerTeacher);
}
usdc.safeTransfer(principal, principalPay);
}

Impact

  1. Without session completion checks, the principal could repeatedly call graduateAndUpgrade, leading to multiple unauthorized upgrades and fund distributions.

2.This could result in the depletion of contract funds and undermine the integrity of the academic process.

Tools Used

Manual code review

Recommendations

  1. Implement Session Completion Check: Add a condition to verify that the current time has surpassed the session end time before allowing graduation and upgrades.

if (block.timestamp < sessionEnd) {
revert("Session is still ongoing.");
}
  1. Introduce a Graduation Status Flag: Maintain a boolean flag (e.g., hasGraduated) to track whether graduation has already occurred, preventing repeated executions.

if (hasGraduated) {
revert("Graduation has already been processed.");
}
hasGraduated = true;
Updates

Lead Judging Commences

yeahchibyke Lead Judge 2 months ago
Submission Judgement Published
Validated
Assigned finding tags:

can graduate without session end

`graduateAndUpgrade()` can be called successfully even when the school session has not ended

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.