Hawk High

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

[H-7] `LevelOne::graduateAndUpgrade` function does not check wether school is in session or not, making it able to upgrade the protocol even if session has not ever started yet

Description: In function graduateAndUpgrade there is no check if the school is in a session or not. This makes it able for the protocol to be upgraded even if the school session has not started yet, breaking one of the protocol's invariants (actually more than just one).

System upgrade cannot take place unless school's sessionEnd has reached

Impact: Protocol can be upgraded even if the school session has not started yet, which is not intended.

Proof of Concept: As we can see the session status is false, meaning the school is not in session, and we can still call graduateAndUpgrade without fail.

function testCanUpgradeToLevelTwoEvenIfSessionHasNotStarted() public {
_teachersAdded();
_studentsEnrolled();
levelTwoImplementation = new LevelTwo();
levelTwoImplementationAddress = address(levelTwoImplementation);
bytes memory data = abi.encodeCall(LevelTwo.graduate, ());
assertFalse(levelOneProxy.getSessionStatus()); // not in session
vm.prank(principal);
levelOneProxy.graduateAndUpgrade(levelTwoImplementationAddress, data); // does not revert
}

Recommended Mitigation: Add a check in graduateAndUpgrade to see if school is in session or not.

function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
+ if (inSession==false) {
+ revert();
+ }
uint256 totalTeachers = listOfTeachers.length;
.
.
.
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge 7 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.

Give us feedback!