DEV Community

Nexus Intelligence Research
Nexus Intelligence Research

Posted on

DeFi Smart Contract Vulnerabilities Audit Guide

Here are three specific DeFi smart contract vulnerabilities commonly identified in professional security audits, described with technical precision suitable for an audit report.

1. Reentrancy Vulnerability (CWE-207)

Description:

Reentrancy occurs when an external smart contract call is made before the internal state changes associated with that call are complete. If the called contract is malicious, it can re-enter the original contract and execute the vulnerable function again before the state update, leading to duplicate withdrawals or state corruption.

Specific Example:

A withdraw() function transfers ETH to the user via address(user).call{value: amount}("") before updating the user’s balance in the contract’s storage mapping (balances[user] -= amount). A malicious user can deploy a contract that, upon receiving ETH, calls withdraw() again. Since the balance hasn’t been decremented yet, the second call also sees the full balance and succeeds, draining the contract.

Top comments (0)