sherlock-audit / 2023-12-dodo-judging

5 stars 4 forks source link

FaisalAli - [N-01] The `nonReentrant` `modifier` should occur before all other modifiers #1

Closed sherlock-admin closed 8 months ago

sherlock-admin commented 8 months ago

FaisalAli

medium

[N-01] The nonReentrant modifier should occur before all other modifiers

Summary

This is a best-practice to protect against reentrancy in other modifiers.

Vulnerability Detail

When developing smart contracts in Solidity, prioritizing security is crucial to prevent vulnerabilities like reentrancy attacks. These attacks exploit a contract's recursive behavior to manipulate it and potentially drain funds. To address this, thenonReentrant modifier is commonly employed as a protective measure, acting as a lock to prevent recursive function calls during execution. To ensure its effectiveness, it is essential to place thenonReentrant modifier at the beginning of a function, before any other modifiers, to prevent bypassing of the reentrancy protection.

Impact

While there is no obvious vulnerability currently with nonreentrant not being the first modifier in the list, it is safer to place it in the first.

Code Snippet

Tool used

Manual Review

Recommendation

It is recommended to place the nonReentrant modifier at the beginning of a function, before any other modifiers.

nevillehuang commented 8 months ago

Invalid, informational finding with no real fund loss/DoS/core contract functionality impact.