Christmas Dinner

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

The `nonReentrant` modifier is written in an incorrect way

Description

The nonReentrant modifier sets locked = false after function execution but does not set locked = true at the start.

Impact

The reentrancy protection is incomplete, allowing potential reentrant calls before the modifier sets locked = false.

Proof of Concepts

  1. The value of the locked variable is false as per L::43

  2. Hence the require(!locked, "No re-entrancy"); statement in the modifier will always pass, not protecting for reentrancy.

Recommended mitigation

Add the following change to the code.

modifier nonReentrant() {
require(!locked, "No re-entrancy");
+ locked = true;
_;
locked = false;
}
Updates

Lead Judging Commences

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