DEV Community

Nexus Intelligence Research
Nexus Intelligence Research

Posted on

DeFi Smart Contract Vulnerabilities Audit Guide

Here are three high-impact DeFi smart contract vulnerabilities, described with specific technical details suitable for inclusion in an audit report. Each entry includes the vulnerability class, a realistic code scenario, the root cause, and potential impact.


1. Reentrancy Attack via Unchecked External Calls

Vulnerability ID: VULN-001

Severity: Critical

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

Description

The withdraw() function in a yield-bearing token contract allows users to claim accumulated rewards and withdraw their principal. The contract performs an external call to transfer tokens to the user before updating the user’s balance or reward share. This violates the "Checks-Effects-Interactions" (CEI) pattern.

Code Example (Vulnerable)


solidity
contract YieldToken {
    mapping(address => uint256) public balances;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)