Christmas Dinner

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

"Improper non-reentrancy lock implementation allows potential reentrancy exploits"

Summary

The nonReentrant modifier in the contract is improperly implemented. The locked state variable is never set to true before executing the function body, which renders the reentrancy guard ineffective. This oversight can allow malicious reentrancy attacks, potentially compromising the contract's logic and security.

Vulnerability Details

The modifier nonReentrant is designed to prevent reentrant calls by setting a lock before execution and releasing it afterward. The locked variable is never assigned the value true before entering the critical code section, leaving the contract vulnerable to reentrancy attacks.

modifier nonReentrant() {
require(!locked, "No re-entrancy"); // Proper check
// locked = true; // Missing assignment
_;
locked = false; // Lock is reset without being set
}

Impact

If exploited, this vulnerability can result in theft of funds or resources from the contract. This poses a high severity risk** **in scenarios where external calls are made, particularly in functions dealing with token transfers, ETH payments, or sensitive state changes, but in this case because of the logic of the contract reentrancy is not possible, but if the host manage to put other tokens it will be possible.

Tools Used

Manual code review

Recommendations

By implementing that fix, the contract will ensure that reentrancy attacks are effectively mitigated.

Correctly set the locked variable to true before function execution:

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