Hawk High

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

Lack of Principal Control in Student Enrollment

Summary

The enroll function allows any external address to register themselves as a student, bypassing the intended control of the principal role. This violates the responsibilities outlined in the project documentation, where the principal is described as responsible for managing the enrollment process. The lack of access control could lead to unauthorized users enrolling as students and exploiting the system.

Vulnerability Details

The enroll function:



function enroll() external notYetInSession {
if (isTeacher\[msg.sender] || msg.sender == principal) {
revert HH\_\_NotAllowed();
}
if (isStudent\[msg.sender]) {
revert HH\_\_StudentExists();
}
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);
}

The function lacks the onlyPrincipal modifier, which should restrict the enrollment process to the principal. As a result:

  1. Anyone can call this function and enroll themselves as a student.

  2. This is inconsistent with the project's documentation, which specifies that the principal is in charge of student management.

Reproducing the Issue

  1. Deploy the contract.

  2. Call initialize to set up the principal and other parameters.

  3. Any address can call enroll and successfully register themselves as a student without the principal's involvement.


Impact

  • Unauthorized Access: Any external address can enroll as a student, potentially inflating the listOfStudents and consuming resources meant for legitimate users.

  • Loss of Control: The principal loses their ability to regulate the enrollment process, contradicting their documented role.

  • Financial Risks: Malicious actors can exploit this to pay the minimum schoolFees repeatedly, manipulating the system or consuming bursary resources.

Tools Used

Manual Code Review

Recommendations

Enforce onlyPrincipal Modifier: Modify the enroll function to restrict its execution to the principal.

Example:

+ function enroll(address student) external onlyPrincipal notYetInSession {
if (isTeacher[student] || student == principal) {
revert HH__NotAllowed();
}
if (isStudent[student]) {
revert HH__StudentExists();
}
usdc.safeTransferFrom(student, address(this), schoolFees);
listOfStudents.push(student);
isStudent[student] = true;
studentScore[student] = 100;
bursary += schoolFees;
emit Enrolled(student);
}

Update Documentation: Clearly define whether the enroll function should be publicly accessible or restricted to the principal.

Updates

Lead Judging Commences

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

Support

FAQs

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