Here are three of the most common and impactful DeFi smart contract vulnerabilities, along with specific detection methods for each.
1. Reentrancy
Vulnerability Description:
Reentrancy occurs when a smart contract calls an external contract before updating its own internal state. An attacker can exploit this by re-entering the vulnerable function (via a callback) before the original execution completes, allowing them to drain funds or manipulate state multiple times. This was famously exploited in the 2016 DAO hack.
Detection Methods:
-
Static Analysis Tools: Use tools like Slither (by Trail of Bits) or Mythril. These tools flag functions that perform external calls (
call,delegatecall) before state changes.-
Example Slither output:
Function calls an external contract before updating internal state. Ensure that no reentrancy is possible.
-
Example Slither output:
- Manual Code Review: Look for the CEI Pattern
Top comments (0)