Blockchain Fundamentals
Blockchain security focuses on smart contracts, consensus mechanisms, and decentralized applications. Understanding the fundamentals is essential for security testing.
Authorised Targets Only
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
The security consequence of immutability is that a deployed contract's bytecode is the final word: a bug cannot be patched in place, only mitigated by a proxy upgrade path or by draining the funds it protects. Everything in this section is therefore assessed at the source level before deployment, which is why the audit method in Auditing carries as much weight as the attack pages.
Security Testing Setup
Build a local chain before you read a single exploit: every sample in this section is meant to be deployed, attacked and fixed against a throwaway network where the only funds at risk are the ones you minted.
# Local development environment
# Install Foundry (recommended)
curl -L https://foundry.paradigm.xyz | bash
foundryup
# Or use Hardhat 3 (needs Node 22.13+)
npm install --save-dev hardhat
npx hardhat --init
# Local blockchain for testing
anvil # Foundry
# or
npx hardhat node
# The samples pin solc 0.8.34. Foundry fetches the compiler the
# pragma asks for through svm on first build; to pull it explicitly:
svm install 0.8.34
# Useful tools:
# - Slither (static analysis, Trail of Bits)
# - Aderyn (static analysis, Rust)
# - Echidna or Medusa (property-based fuzzing)
# - Foundry forge (unit tests, fuzzing, invariants)
# - Halmos (symbolic execution)
pip install slither-analyzer
cargo install aderyn
Two mainnet upgrades decide what that compiler is allowed to emit, and both change the assumptions the later pages
rely on. Pectra (May 2025) added
EIP-7702, which
lets an externally owned account point its own code at a contract — see
Account Abstraction,
Access Control
and
Wallet Security.
Fusaka (December 2025) is the live mainnet fork; Glamsterdam is next but unscheduled. The compiler targets the
newest fork its own release knows about, which is why
solc 0.8.34
emits bytecode that a chain which has not taken that fork will reject.
Check the target chain's fork level before you deploy, and lower the target explicitly when it lags. The samples
here pin 0.8.34 rather than the current 0.8.38 deliberately: 0.8.34 is the first release carrying the
transient-storage and intermediate-representation high-severity fix, and the releases above it are very recent.
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 |
Related Topics
Solidity Security
The language-level patterns — tx.origin, unchecked transfers, delegatecall — that the categories above turn into.
Reentrancy
The canonical exploit, the attacker contract that performs it, and the two fixes.
Cryptography Attacks
What breaks the hashing and signature assumptions a chain is built on.