07.SWC-107_Reentrancy
2023-07-13 16:10:58
# 09.SWC
SWC-107_Reentrancy
State Variable Default Visibility
- Description: One of the major dangers of calling external contracts is that they can take over the control flow. In the reentrancy attack (a.k.a. recursive call attack), a malicious contract calls back into the calling contract before the first invocation of the function is finished. This may cause the different invocations of the function to interact in undesirable ways.
- Remediation: The best practices to avoid Reentrancy weaknesses are:
- Make sure all internal state changes are performed before the call is executed. This is known as the Checks-Effects-Interactions pattern
- Use a reentrancy lock (ie. OpenZeppelin’s ReentrancyGuard.
vulnerability contract
1 | pragma solidity ^0.5.0; |