Cointegrity

Reentrancy Guards

Web3 / smart contracts

Reentrancy guards are security mechanisms that prevent reentrancy attacks by blocking recursive function calls before a contract's state has been fully updated. These guards typically use a status flag or mutex pattern that tracks whether a function is currently executing, preventing external calls from triggering the same function again while it's still processing. Common implementations include the "checks-effects-interactions" pattern, mutex locks, and pull-over-push payment mechanisms that fundamentally prevent attackers from exploiting state inconsistencies during contract execution. Example: OpenZeppelin's ReentrancyGuard contract uses a state variable to track function execution status, preventing reentrancy by reverting any recursive calls until the original function completes and state updates finalize. Why it matters for smart contracts: Reentrancy attacks have enabled some of the largest cryptocurrency exploits, including the 2016 DAO hack. Guards are essential for contracts handling withdrawals, transfers, or external calls, protecting user assets from sophisticated attack patterns.

Category: smart contracts, wallets security

Explore the full Web3 Glossary — 2,062+ expert-curated definitions. Need guidance? Talk to our consultants.