Christmas Dinner

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

Inconsistent Use of the nonReentrant Modifier

Summary

The current implementation of the nonReentrant modifier does not properly prevent reentrancy by setting the locked state variable at the right place in the modifier.

Vulnerability Details

  • The locked state variable is only set to false at the end of the modifier, which can potentially allow reentrancy during the execution of the function.

  • It is important to set locked = true at the start of the modifier to prevent reentrancy attacks from triggering during the function execution.

Impact

  • A reentrancy attack could happen.

Tools Used

  • Manual code review.

Recommendations

Update the nonReentrant modifier to ensure that locked is set to true at the start of the function. This prevents reentrancy attacks more effectively. The corrected modifier should look as follows:

modifier nonReentrant() {
require(!locked, "No re-entrancy");
locked = true; // Lock at the start of the modifier
_;
locked = false; // Unlock at the end of the function
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 11 months 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.