Christmas Dinner

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

Reentrancy guard is implemented incorrectly

Bug description

While there is a nonReentrant modifier, it's implemented incorrectly.:

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

The lock is always set to false at the end of the function, regardless of its initial state. The correct implementation should set locked = true at the start and locked = false at the end. At this moment the reentrancy guard has no protection at all, therefore all functions with nonReentrant modifier are still vulnerable to reentrancy attacks.

Recommendation

Fix the reentrancy guard:

modifier nonReentrant() {
require(!locked, "No re-entrancy");
locked = true; // Set to true at start
_;
locked = false;
}
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.