Christmas Dinner

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

[H-2] function `ChristmasDinner::refund` uses nonReentrant modifeir , which is intended to prevent reentrancy attacks. However, the modifier is not implemented correctly.

**Description:** in the `refund` function, nonReentrant modifier is used, but well implemented.
the locked state is only checked at the start,but it is reset to false after the function logic.
```javascript
modifier nonReentrant() {
require(!locked, "No re-entrancy");
_;
locked = false;
}
```
**Impact:** If an attacker can re-enter the function before locked is set back to false, they could exploit the contract draining funds or causing unintended behavior.
**Proof of Concept:**
**Recommended Mitigation:**
1. consider using Openzeppelin's ReentrancyGuard implementation
2. The locked state should be set to true immediately before the function logic (_) and reset to false only after the logic is executed. A proper implementation should look like this:
```diff
modifier nonReentrant() {
require(!locked, "No re-entrancy");
+ locked = true; // Set lock before the function execution
_;
locked = false; // Reset lock after the function execution
}
```
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!