The graduateAndUpgrade
function transfers funds to the principal and teachers based on the bursary
amount, but fails to update the bursary
state variable after these transfers. This leads to two serious consequences:
Reentrancy Risk: An attacker can re-enter the function before the bursary is updated, draining the contract repeatedly.
Incorrect Accounting: The bursary
value remains at 100%, misrepresenting the actual funds left and breaking protocol invariants.
This is a classic case of violating the Checks-Effects-Interactions pattern. By not updating the state (bursary) before external calls, the function allows for both inaccurate accounting and potential reentrancy exploits.
bursary = 1000 USDC
On first call:
50 USDC sent to principal (5%)
350 USDC sent to teachers (35%)
bursary
remains 1000 USDC → wrong
On second call:
Transfers again calculated based on full 1000 USDC
Another 400 USDC drained
Result: 800 USDC withdrawn instead of only 400, leaving only 200 USDC instead of the expected 600
Protocol Security: Allows for repeated draining of funds using stale bursary
values.
Accounting Errors: Leads to double-counting and misrepresentation of funds.
Loss of Funds: Users can withdraw more than intended due to repeated calculations based on the original bursary
.
Manual review
Update the bursary
state before making any external transfers:
Checks-Effects-Interactions Pattern:
Always update internal state (bursary) before calling external functions.
Accurate Bursary Tracking:
The updated bursary
now correctly reflects the remaining 60% after payments.
Reentrancy Resistance:
Prevents re-entrant calls from recalculating based on outdated values.
Financial Integrity: Maintains the correct bursary value post-payment to ensure smooth upgrades and accurate fund flow.
Protocol Security: Eliminates the risk of fund draining via reentrancy or duplicate withdrawals.
Invariant Compliance: Complies with the protocol’s design, where 60% of the bursary is preserved post-upgrade for future use.
The bursary is not updated after wages have been paid in `graduateAndUpgrade()` function
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.