Christmas Dinner

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

Susceptibility To Reentrancy Attack

Summary

The refund() function is susceptible to a reentrancy attack due an improperly defined nonReentrant modiifer as well as the non use of the CEI pattern.

Vulnerability Details

The refund() function is defined with a nonReentrant modifier. However, this modiifier will not prevent a reentrancy attack as lock is never set to true before the function is invoked. This means that the function is actually not locked when called and can be reentered. Also, because the function does not follow the CEI pattern there is no additional safeguard against the attack.

Impact

This means that a attacker is able to drain the contract of it's funds by recursively calling refund().

Tools Used

Manual review.

Recommendations

Update the nonReentrant modifier as follows:

modifier nonReentrant() {
require(!locked, "No re-entrancy");
lock = true;
_;
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!