layeraudits.felconsec.co.za

Blockchain Security Taxonomy

Comprehensive training guide and visualization based on the MDPI sustainability article. Learn how to identify vulnerabilities at each layer of the blockchain ecosystem.

Downloadable Resources

The 7-Layer Framework

How to think and look for issues across the concentric security layers.

Layer 1 — Physical

Think: "Where are the keys?"
  • • Look for: Single-sig ownership, software wallets, cloud-stored keys
  • • Ask: Who has physical access? Is multi-sig configured?
REAL CASE

Bybit ($1.5B) — compromised dev machine → social engineered multi-sig signers

Layer 2 — Data

Think: "Can data be malformed?"
  • • Look for: block.timestamp dependency, raw calldata parsing, missing replay protection
  • • Ask: What happens with malformed input? Are signatures verified?
RED FLAG

Using block.timestamp for critical timing (miners can manipulate ±15 sec)

Layer 3 — Network

Think: "Who sees what in the mempool?"
  • • Look for: Front-runnable functions, no commit-reveal patterns, ordering assumptions
  • • Ask: Can someone see this transaction coming and profit from it?
REAL CASE

MEV bots extract $100M+/year via mempool inspection

Layer 4 — Consensus

Think: "What if blocks reorganize?"
  • • Look for: Immediate finality assumptions, no reorg handling in bridges
  • • Ask: What happens if this block gets reverted?
REAL CASE

Cross-chain bridges exploited via chain reorgs

Layer 5 — Incentive

Think: "Can incentives be gamed?"
  • • Look for: Rewards based on spot balances, no cooldowns, penalties < gains
  • • Ask: Can a rational actor profit by harming the protocol?
REAL CASE

Yield farms drained via flash-loaned spot balance manipulation

Layer 7 — Application

Think: "Can users be tricked?"
  • • Look for: User-provided contract addresses, missing tx verification in UI
  • • Ask: Can the frontend be manipulated to show false info?
REAL CASE

Transit Swap ($21M) — frontend address validation bug

Layer 6 — Contract Primary Focus

Auditor's Thought: "Where is the money, and who controls it?"
Sub-skill How to Find It Red Flag Example
Reentrancy External calls before state updates call.value before balances[msg.sender] = 0
Access Control Public functions with no modifiers function mint() public — anyone can mint
Integer Math Division before multiplication (a / b) * c — loses precision
Oracle Spot price dependency balanceOf(pair) used as price
Flash Loans Single-tx value extraction Reward based on current LP balance
Business Logic Code ≠ intended behavior donateToReserves() creating unbacked debt

The Auditor's Mental Checklist

auditor-checklist.sh
#!/bin/bash
# Core questions for every smart contract audit
  1. WHO can call this?→ Access control
  2. WHAT if this is zero?→ Edge cases
  3. CAN this be recursive?→ Reentrancy
  4. WHERE does this price come from?→ Oracle
  5. CAN I do this in one tx?→ Flash loan
  6. WHAT if order is reversed?→ Business logic
  7. IS this fresh or stale?→ Oracle freshness
  8. CAN I grief this?→ DoS / economic attack
auditor@web3:~$