Hawk High

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

CEI Pattern not followed in `LevelOne::enroll`

Summary

CEI Pattern not followed in LevelOne::enroll function

Vulnerability Details

In LevelOne::enroll function external function call are made before the contract state changes effects which is against the CEI Pattern(Checks, Effects, Interactions).

usdc.safeTransferFrom(msg.sender, address(this), schoolFees);
listOfStudents.push(msg.sender);
isStudent[msg.sender] = true;
studentScore[msg.sender] = 100;
bursary += schoolFees;
emit Enrolled(msg.sender);

Impact

Some form of reentrancy bugs can arise if CEI pattern is not followed properly.

Recommendations

We should do the contracts state changes before the external contract function calls.

- usdc.safeTransferFrom(msg.sender, address(this), schoolFees);
listOfStudents.push(msg.sender);
isStudent[msg.sender] = true;
studentScore[msg.sender] = 100;
bursary += schoolFees;
emit Enrolled(msg.sender);
+ usdc.safeTransferFrom(msg.sender, address(this), schoolFees);
Updates

Lead Judging Commences

yeahchibyke Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
yeahchibyke Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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