Reentrancy Guard
A Reentrancy Guard is a security mechanism implemented in smart contracts to prevent unauthorized recursive calls during the execution of a function. It typically uses a boolean flag or a state variable that is checked at the beginning of a function and updated upon completion.
If a function is called while the flag indicates that a previous execution is still in progress, the transaction is reverted. This is vital in DeFi protocols, especially those involving token transfers or external calls, to prevent attackers from repeatedly withdrawing funds before the contract updates its internal balance.
By enforcing this guard, developers create a defensive layer that maintains the integrity of the contract state. It is a fundamental pattern for protecting liquidity pools and vault structures against malicious callback exploits.