Christmas Dinner

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

Modifier nonReentrant() fails to protect reentrancy attack

Summary

Modifier nonReentrant() fails to protect reentrancy attack since it nevers sets locked to false.

Vulnerability Details

The nonReentrant modifier in the provided smart contract fails to adequately protect against reentrancy attacks due to improper management of the locking mechanism. Specifically, the locked boolean is never set to true at the start of a function call, thereby rendering the require(!locked, "No re-entrancy"); check ineffective. This oversight allows for potential reentrancy attacks where an attacker could repeatedly re-enter functions such as refund(), leading to unintended withdrawals or other state manipulations before the initial function execution completes. This vulnerability could be exploited to drain contract funds or disrupt contract operations, underscoring the need for careful implementation of mutex mechanisms in smart contracts that perform external calls or state changes.

Impact

The impact of the improperly implemented nonReentrant modifier in the smart contract is considerable, primarily exposing the contract to potential financial losses through reentrancy attacks where attackers could drain funds by repeatedly invoking refund or withdrawal functions. This vulnerability also compromises the integrity of the contract's data, leading to inconsistent states and disrupted functionality, such as participant management and contribution handling. Moreover, exploitation of this vulnerability could result in significant reputation damage for the developers or associated entities, and potentially invoke legal and compliance issues if users suffer financial losses due to these security oversights. Addressing these vulnerabilities with rigorous testing and revision is crucial to ensure the contract's security and reliability.

Tools Used

foundry

Recommendations

change it to:

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