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 Attack via Unchecked External Calls

Vulnerability Type: CWE-841 (Improper Enforcement of Behavioral Workflow)

Severity: High

Description:

The withdraw() function in the Vault.sol contract allows users to withdraw funds by calling token.transfer(msg.sender, amount). This external call to the ERC-20 token contract occurs before the user’s balance in the vault is updated (i.e., before balances[msg.sender] -= amount). If the token is a malicious or non-standard ERC-20 implementation (e.g., one that triggers a callback during transfer), an attacker can re-enter the withdraw() function before the state variable is updated. This allows the attacker to drain the vault multiple times using the same initial balance.

**Example Sn

Top comments (0)