OXAUDIT WHITEPAPER
Request an Audit
  • 🔋OXAUDIT ECOSYSTEM: Where Blockchain Security Meets Education
  • 🛡️SERVICES
    • Smart Contract Audits
      • What is a Smart Contract Audit?
      • Types of Vulnerabilities Detected
        • Reentrancy Attacks
        • Integer Overflows/Underflows
        • Access Control Issues
        • Logic Errors
        • Gas Optimization
        • Front-Running
        • Denial of Service (DoS) Attacks
      • Audit Process Overview
    • DApp Auditing
      • Introduction to DApp Security
      • Common Risks in DApp Development
      • How OXAudit Assesses DApp Security
    • Penetration Testing
      • What is a Penetration Testing
      • Tools and Techniques Used
      • Best Practices and Recommendations
    • Layer 2 Scaling Audits
      • What is a Layer 2 Security
      • Common Layer 2 Vulnerabilities
      • OXAudit’s Layer 2 Auditing Approach
  • 🛡️TOOLS
    • AI Vulnerabilities Finder
    • Multi-chain Contract Scan
      • Overview and Purpose
      • Supported Contract Types
      • Running an Initial Scan
  • 🛡️OXAUDIT ANALYTICS FRAMEWORK
    • OXAudit Solidity Framework:Core Functions
    • Step-by-Step Guide
    • Benefits
      • for Developers
      • for Trader
    • Upcoming Features
  • 🛡️FEATURES
    • Revenue Sharing Model
      • Overview
      • Tiers
      • Distribution Mechanics
      • Benefits to Holders
    • OXAudit Educational Program
      • Introduction
      • Program Overview
      • Core Features of the Program
    • API Reference
      • Authentication
      • Endpoints
      • Parameters
      • Response Formats
      • Error Codes
    • Tokenomics
  • ⚖️LEGAL
    • TERM AND CONDITION
    • PRIVACY POLICY
  • đź’»OFFICIAL LINKS
    • WEBSITE
    • TWITTER
    • TELEGRAM
    • Dapp
    • BLOGS
Powered by GitBook
On this page
  • Key Problem in the Vulnerable Code
  • How Reentrancy Attacks Work
  1. SERVICES
  2. Smart Contract Audits
  3. Types of Vulnerabilities Detected

Reentrancy Attacks

A Reentrancy Attack is a common vulnerability in smart contracts that occurs when a malicious contract repeatedly calls a function (often the withdraw function) in another contract before the initial execution is complete. This allows the attacker to drain funds from the vulnerable contract before it has a chance to update its state (like account balances).

Key Problem in the Vulnerable Code

The vulnerable function performs Interactions (sending Ether) before Effects (updating the contract’s state). Here’s an example:

solidity

function withdraw(uint256 _amount) public {
    require(balances[msg.sender] >= _amount, "Insufficient balance");

    // Sending Ether before updating the balance (vulnerable)
    (bool success, ) = msg.sender.call{value: _amount}("");
    require(success, "Transfer failed");

    // Updating balance after sending Ether
    balances[msg.sender] -= _amount;
}

How Reentrancy Attacks Work

  1. Setup: The attacker deposits Ether into the vulnerable contract.

  2. Withdrawal: The attacker calls the vulnerable contract’s withdraw function to withdraw their deposit.

  3. Reentrant Call: During the withdrawal, the vulnerable contract sends Ether to the attacker’s contract. The attacker’s contract triggers a reentrant call to the withdraw function before the vulnerable contract updates its balance.

  4. Repeat and Drain: The attacker repeats this process in a loop, withdrawing funds multiple times, until the vulnerable contract runs out of Ether.

PreviousTypes of Vulnerabilities DetectedNextInteger Overflows/Underflows

Last updated 6 months ago

🛡️