Medium
The contract lacks explicit reentrancy guards on functions that interact with external ERC20 tokens. While SafeERC20 is used, this doesn't protect against cross-function reentrancy attacks involving tokens with callbacks like ERC777 or certain deflationary tokens that might have been wrapped in an ERC20 interface.
The enroll()
and graduateAndUpgrade()
functions perform token transfers but don't follow the Checks-Effects-Interactions pattern, leaving them potentially vulnerable to reentrancy.
This vulnerability could be exploited as follows:
A malicious actor gets added as a teacher (possibly through social engineering or a compromised principal)
They deploy a malicious contract with callback functionality that serves as their "teacher" address
When graduateAndUpgrade()
is called:
The malicious implementation is authorized via _authorizeUpgrade(_levelTwo)
The contract makes external token transfers to teachers
When paying the malicious teacher contract, its callback function activates
The callback could manipulate the contract state during this vulnerable transitional period:
Since the UUPS upgrade is already authorized but transfers are still executing from the old implementation, this creates a unique attack window
Additionally, the enroll()
function has similar reentrancy concerns:
While standard USDC doesn't implement callbacks, if the contract is deployed on chains where USDC is implemented differently or if Circle upgrades the USDC implementation to include callback mechanisms in the future, this could expose the contract to risk.
Add a reentrancy guard
Reorder operations to follow Checks-Effects-Interactions pattern
Most critically, ensure the contract upgrade in graduateAndUpgrade()
happens AFTER all token transfers to prevent reentrancy during this critical operation
State changes are not made before external calls. In the case of the `enroll()` function this is a design choice and the best mitigation will be a `nonReetrant` modifier. In the case of the `graduateAndUpgrade()` function, `CEI` should be followed. Informational
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.