4 min read

Web3 Security
Advanced

Blockchain & Smart Contract Security

Blockchain and smart contract security focuses on vulnerabilities in decentralized applications (dApps), DeFi protocols, and cryptocurrency systems. Unlike traditional applications, smart contract bugs are immutable once deployed—a single vulnerability can result in millions of dollars stolen. This guide covers Solidity security, common attack patterns, and audit methodology.

Authorised Targets Only

Every exploit on these pages is for contracts you deploy yourself on a local chain (Foundry/Anvil or Hardhat) or a testnet you control. Running one against a deployed contract that holds other people's funds is theft, not testing: unauthorised exploitation is a criminal offence in most jurisdictions and can also amount to a securities or commodities violation. Get a written engagement scope before you touch anything you did not deploy, and never point a mainnet private key at a sample from this section.

Immutability = Permanent Bugs

Smart contracts deployed on Ethereum mainnet are immutable (unless using proxy patterns). A vulnerability cannot be patched—it remains exploitable forever. Always test on a testnet first: Sepolia for application logic, and Hoodi for validator and staking work. Holesky was deprecated and shut down in September 2025, so any guide that still sends you there is out of date.

Smart Contract Attack Surface

Smart Contract

  • Reentrancy vulnerabilities
  • Integer overflow/underflow
  • Access control bugs
  • Front-running attacks
  • Delegatecall injection

DeFi Protocol

  • Flash loan attacks
  • Oracle manipulation
  • Liquidity pool exploits
  • Price manipulation
  • Governance attacks

Wallet/User

  • Phishing attacks
  • Private key theft
  • Malicious transaction signing
  • Rug pulls / exit scams
  • Social engineering

Common Smart Contract Vulnerabilities

1. Reentrancy (The DAO Hack)

External contract calls before state updates allow attacker to recursively drain funds. Famous $60M DAO hack in 2016.

(bool ok, ) = victim.call{value: amount}(""); // BAD: sends ETH before updating balance

2. Integer Overflow/Underflow

Arithmetic operations exceeding uint256 max (2^256-1) wrap around to zero. Fixed in Solidity 0.8.0+ with automatic checks.

uint256 balance = 0; balance -= 1; // underflows to MAX_UINT

3. Access Control Bugs

Missing or incorrect onlyOwner modifiers allow unauthorized users to call privileged functions.

function withdrawAll() public {} // BAD: anyone can withdraw

4. Unchecked External Calls

Failing to check return value of send() or call() can result in silent failures.

addr.send(amount); // BAD: doesn't revert on failure

Landmark Crypto Hacks

Date Project Loss Vulnerability
2016-06 The DAO $60M Reentrancy attack
2021-08 Poly Network $610M Cross-chain bridge exploit
2022-03 Ronin Network $625M Validator key compromise
2022-10 Mango Markets $114M Oracle price manipulation
2023-03 Euler Finance $197M Flash-loan donation attack on solvency checks
2023-07 Curve pools (Vyper) ~$70M Compiler bug: reentrancy lock failed in Vyper 0.2.15
2025-02 Bybit $1.46B Compromised Safe signing interface; cold-wallet keys
2025-05 Cetus Protocol (Sui) ~$223M Missing overflow check in a shared liquidity-math helper (Move)

Smart Contract Testing Tools

Static Analysis

  • Slither (Trail of Bits)
  • Aderyn (Cyfrin)
  • Semgrep (Solidity rules)
  • Halmos (symbolic)

Fuzzing

  • Echidna
  • Medusa
  • Foundry (forge fuzz, invariants)
  • Diligence Fuzzing

Testing Frameworks

  • Foundry (forge, anvil, cast)
  • Hardhat
  • Ape (Python)
  • Tenderly (fork simulation)

Billions Lost, Same Bug Classes

Bybit's February 2025 loss of roughly $1.46B in ETH is still the largest single crypto theft on record (Chainalysis, Elliptic), and Chainalysis put total funds stolen from crypto platforms in 2025 at more than $3.4B, with Bybit alone accounting for roughly $1.46B of it. TRM Labs counts about $2.87B across roughly 150 incidents for the same year — the gap is a methodology difference, so quote whichever estimate you use with its source. Very few of those cases broke a cryptographic primitive: they broke key custody, signing interfaces, access control, or a price oracle. Audit before mainnet deployment, and treat operational trust assumptions as part of the attack surface.

Audit Checklist

  • ✓ Reentrancy: Checks-Effects-Interactions pattern enforced?
  • ✓ Access Control: All privileged functions have proper modifiers?
  • ✓ Integer Arithmetic: Solidity 0.8.0+ checked arithmetic, and every unchecked block justified?
  • ✓ External Calls: Return values checked? Gas limits considered?
  • ✓ Oracle Security: Using decentralized oracles (Chainlink)? Time-weighted average price (TWAP)?
  • ✓ Flash Loan Resistance: Critical operations protected against single-block attacks?
  • ✓ Upgradeability: If using proxies, is upgrade mechanism secure?
  • ✓ Front-Running: Critical functions protected against MEV attacks?

Guide Contents