Skip to main content

Do Reentrancy Guards Protect against Both Single-Function and Cross-Function Attacks?

Yes, a properly implemented reentrancy guard can protect against both types of attacks. The guard typically uses a lock that is applied at the contract level, not just for a single function.

When any function with the guard modifier is entered, the lock is activated. If an external call from this function leads to a re-entrant call to any other function that also has the guard, the second function will see the lock is active and will revert the transaction.

This prevents both recursive calls to the same function and calls to other state-sharing functions within the contract.

Are There Scenarios Where the Checks-Effects-Interactions Pattern Is Insufficient?
What Is a “Preimage Attack” and How Does It Differ from a Collision Attack?
Why Are Cross-Function Reentrancy Attacks Generally Harder to Detect?
How Do Solidity Modifiers like Nonreentrant Implement the CEI Principle?