Blockchain Fundamentals

Basics

Blockchain security focuses on smart contracts, consensus mechanisms, and decentralized applications. Understanding the fundamentals is essential for security testing.

Blockchain Architecture

Core Components

  • • Distributed ledger
  • • Consensus mechanism
  • • Cryptographic hashing
  • • Digital signatures

Smart Contracts

  • • Self-executing code
  • • Immutable once deployed
  • • EVM (Ethereum)
  • • Gas-based execution

Security Testing Setup

blockchain-setup.sh
bash
# Local development environment

# Install Foundry (recommended)
curl -L https://foundry.paradigm.xyz | bash
foundryup

# Or use Hardhat
npm install --save-dev hardhat
npx hardhat init

# Local blockchain for testing
anvil  # Foundry
# or
npx hardhat node

# Useful tools:
# - Slither (static analysis)
# - Mythril (symbolic execution)
# - Echidna (fuzzing)
# - Foundry forge (testing)

pip install slither-analyzer
pip install mythril

Common Attack Categories

Category Examples
Reentrancy The DAO hack, cross-function
Access Control Missing modifiers, tx.origin
Integer Issues Overflow, underflow
Flash Loans Price manipulation, governance