Reentrancy Guard
A defensive smart contract pattern that prevents a function from being called again before its first execution finishes, specifically to block reentrancy attacks.
A reentrancy guard is a defensive smart contract pattern that prevents a function from being called again ("re-entered") before its first execution has fully finished, specifically to block the reentrancy attack (see Kaavon's "Reentrancy Attack" glossary definition) technique, where a malicious contract exploits an interrupted function call to repeatedly drain funds before the original call's state updates complete.
A reentrancy guard is now considered a standard, widely-adopted defensive pattern for any function that sends funds or calls an external, untrusted contract, specifically because the underlying reentrancy vulnerability has caused several real, large, well-documented exploits historically.
Examples
- A reentrancy guard blocks a function from being called again before its first execution finishes, directly preventing the reentrancy attack technique.
- Reentrancy guards are now a standard, widely-adopted defensive pattern specifically because the underlying vulnerability has caused several real, large historical exploits.