Here are three of the most common and critical DeFi smart contract vulnerabilities, along with specific methods to detect them during auditing or development.
1. Reentrancy Attacks
Description:
Reentrancy occurs when a smart contract calls an external contract and sends Ether or tokens before updating its internal state. A malicious external contract can then "re-enter" the vulnerable function before the original call completes, potentially draining funds. This is famously known from the DAO hack.
How to Detect It:
-
Static Analysis: Use tools like Slither (by Trail of Bits) or Mythril. These tools analyze the control flow graph and flag functions that perform external calls (
call,delegatecall,send,transfer) before state changes (e.g.,balance[addr] -= amount). -
Code Review Pattern: Look for the Checks-Effects-Interactions (CEI) pattern violation.
- ✅ **
Top comments (0)