Hawk High

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

Potential Reentrancy attack.

Summary:** **There wasn't an updated state for the bursary before the transfer.

Vulnerability Details: The graduateAndUpdatefunction is vulnerable to reentrancy attack because it didnt update the state of the bursary before the external call safeTransfer was made.

Impact : Proof of Concept

Suppoing USDC implements a callback in the safeTransfer, an attacker could make one of the listOfTeachers address be a contract that reenters the graduateAndUpdatefunction. This could lead to multiple payouts before the function completes, potentially draining funds.

```solidity
contract MaliciousTeacher {
address public vulnerableContract;

contract MaliciousTeacher {
address public vulnerableContract;
constructor(address _vulnerable) {
vulnerableContract = _vulnerable;
}
// This function is triggered during `safeTransfer`
fallback() external payable {
// Re-enter the contract while it's still processing
IVulnerable(vulnerableContract).graduateAndUpgrade(address(this), "");
}
}

Tools Used

Recommendations

The best way to be fully proctected agains reentrancy attacks is to update the state of the bursary and follow the CEI (Checks - Effects - Interactions) pattern for making transfers or sending tokens. Another available option of protection is to use the Open Zepplin's reentrancyguard to safe guard the whole contract from any form of reentrancy attacks.

Updates

Lead Judging Commences

yeahchibyke Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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