Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

The `cutOffScore` could exceed the allowed score which is 100

Summary

To set the cutOffScore the principal must call the LevelOne::startSession function with the cutOffScore passed as an argument, but the thing is when a student enroll for the contract, the maximum score they can get is 100 (as the student got a bad review, their review will be reduced by 10, and if got a positive review their score will remains constant with no change), so if the principal set the cutOffScore to a score above 100 no student will be able to graduate although they haven't got any bad review.

Vulnerability Details

1- Navigate to test/LeveOnelAndGraduateTest.t.sol file.

2- Add the following PoC code to the test file:

function testCutOffScoreCanBeMoreThan100() public {
_studentsEnrolled();
vm.prank(principal);
levelOneProxy.startSession(1000);
console2.log(
"Maximum score clara can get is : ",
levelOneProxy.studentScore(clara)
);
console2.log(
"Maximum score dan can get is : ",
levelOneProxy.studentScore(dan)
);
console2.log("The cutOff Score is : ", levelOneProxy.cutOffScore());
}

3- in the command line, run the following command: forge test --match-test testCutOffScoreCanBeMoreThan100 -vvv

4- the output would be :

Maximum score clara can get is : 100
Maximum score dan can get is : 100
cutOff Score is : 1000
Suite result: ok. 1 passed; 0 failed; 0 skipped

Impact

Any student who doesn't meet the cutOffScore should not be upgraded, so if the principal set the cutOffScore to a value greater than 100, no student will be able to graduate although they haven't got any bad review.

Tools Used

  • Manual Recon

  • foundry test suite


Recommendations

in the LevelOne::startSession function, add the following check :

+ if (_cutOffScore > 100) {
+ revert();
+ }
sessionEnd = block.timestamp + 4 weeks;
Updates

Lead Judging Commences

yeahchibyke Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
yeahchibyke Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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