Hawk High

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

The principal can upgrade at will

Summary

Due to the lack of checks, the principal can upgrade at will.

Vulnerability Details

The vulnerability is located in the graduateAndUpgrade() function of the LevelOne.sol file.

The following is the description of the contract:

Students must have gotten all reviews before system upgrade. System upgrade should not occur if any student has not gotten 4 reviews (one for each week);

Any student who doesn't meet the cutOffScore should not be upgraded;

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

Students must receive four reviews and all of them must meet the cutOffScore before the system can be upgraded. However, the principal can call this function at will.

Impact

This can lead to the principal violating the rules.

Recommendations

Add some necessary check logic.

function graduateAndUpgrade(address _levelTwo, bytes memory) public onlyPrincipal {
if (_levelTwo == address(0)) {
revert HH__ZeroAddress();
}
// add
require(block.timestamp > sessionEnd + reviewTime, "Still within the session time");
uint256 totalStudents = listOfStudents.length;
for (uint256 n = 0; n < totalStudents; n++) {
require(reviewCount[listOfStudents[n]] == 4, "Not having received all the reviews");
require(studentScore[listOfStudents[n]] >= cutOffScore, "Some students have not passed");
}
...
}
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.