DEV Community

Nexus Intelligence Research
Nexus Intelligence Research

Posted on

DeFi Smart Contract Vulnerabilities Audit Guide

Here are three common DeFi smart contract vulnerabilities, along with specific detection methods and tools:

1. Reentrancy

Description:

An attacker calls a contract function that sends ETH or tokens to an external contract (e.g., transfer or call). Before the state update (e.g., balance deduction) is completed, the external contract re-enters the same function, allowing the attacker to manipulate state multiple times.

How to Detect:

  • Static Analysis Tools:
    • Slither: Use the reentrancy detector. It flags functions that perform external calls (call, delegatecall, send, transfer) before updating state variables.

python
    # Example Slither output
    [Medium] Reentrancy in Function:
    - Contract: `MyToken`
    - Function: `withdraw(uint256)`
      - External call: `address.transfer(amount)`
Enter fullscreen mode Exit fullscreen mode

Top comments (0)