The graduate
function in the LevelTwo
contract is implemented with a reinitializer(2)
modifier but lacks any access control mechanism. This means any address can call this function, which should logically be restricted to authorized roles like the principal, as it represents a critical system transition.
Unrestricted access to the graduate
function allows any external actor to trigger the reinitialization of the contract. This can lead to unauthorized graduation procedures, potential manipulation of system state, and disruption of the entire educational platform's operation. Since this function is designed to be the entry point for contract reinitialization during an upgrade, unauthorized access could result in complete system hijacking.
The likelihood of exploitation is high because:
The function is public with no access restrictions
It has a simple signature with no parameters, making it easy to call
The reinitializer(2)
modifier only prevents multiple initializations but doesn't restrict who can perform the initialization
The vulnerable code in LevelTwo
contract:
Comparing with LevelOne
contract's access-controlled functions:
The LevelOne
contract appropriately uses the initializer
modifier for its initialization function and restricts upgrade functionality with onlyPrincipal
. In contrast, LevelTwo
's graduate
function only uses reinitializer(2)
which ensures the function can only be called once but places no restrictions on who can call it.
OpenZeppelin's reinitializer
only prevents multiple initializations but does not provide any access control:
This creates a situation where any external address can trigger the graduation process, which should logically be restricted to an authorized role.
Implement proper access control on the graduate
function:
Alternatively, if the function is meant to be called only by the proxy during an upgrade, it should implement logic to verify it's being called in the context of a proxy upgrade transaction.
The system doesn't implement UUPS properly.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.