Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Incorrect nonReentrant Modifier Implementation

Vulnerability Details

The key issue is that locked = false is not set to true before the function execution (_). This means that when the actual function executes at _;, the lock is still false. This completely defeats the purpose of the reentrancy guard, as the lock state isn't maintained accurately during function execution.

modifier nonReentrant() {
require(!locked, "No re-entrancy");
_;
@> locked = false;
}

Impact

Could lead to reentrancy which leads to loss of ether in the contract when a user who registered using eth calls for refund within the deadline duration

Tools Used

foundry

Recommendations

modifier nonReentrant() {
require(!locked, "No re-entrancy");
//locked initially set to true
+ locked = true;
//executes the function while locked is still true, therefore reentrancy is blocked
_;
locked = false;
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

mutex lock incomplete

Support

FAQs

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

Give us feedback!