1 of 24

Bug Hunting in Smart-Contracts:

Where to Begin

Nikita Stupin

nikita@openzeppelin.com

2 of 24

Our mission is to protect �the open economy

OpenZeppelin is a software company that provides security audits and products for decentralized systems.

Projects from any size - from new startups to established organizations - trust OpenZeppelin to build, inspect and connect to the open economy.

3 of 24

How I got into

smart-contract bug hunting

4 of 24

Where to begin (theory)

5 of 24

Where to begin (practice)

  • Ethernaut
  • Damn Vulnerable DeFi
  • Capture the Ether (*)
    • https://capturetheether.com

6 of 24

Decentralized Application stack

  • JavaScript front-end or mobile application
  • A “wallet” software
    • MetaMask
  • A blockchain node (cloud or local)
  • Smart-contracts
  • Execution layer of a blockchain
    • EVM
  • Consensus layer of a blockchain

https://www.notonlyowner.com/learn/what-happens-when-you-send-one-dai

7 of 24

The vulnerability landscape

8 of 24

What are the main focus areas

Area

Example technologies

Example program

Smart-contracts

Solidity and Vyper

Wallets and DApp front-end

JavaScript and browser extensions

Nodes

Golang, Rust, and consensus algorithms

Cryptography

Zero-knowledge cryptography

9 of 24

DASP Top 10 (2018)

  1. Reentrancy
  2. Access Control
  3. Arithmetic
  4. Unchecked Low Level Calls
  5. Denial of Services
  6. Bad Randomness
  7. Front Running
  8. Time Manipulation
  9. Short Addresses
  10. Unknown Unknowns

https://dasp.co

10 of 24

DASP Top 10 (2022)

  • Reentrancy
  • Access Control
  • Arithmetic
  • Unchecked Low Level Calls
  • Denial of Services
  • Bad Randomness
  • Front Running
  • Time Manipulation
  • Short Addresses
  • Unknown Unknowns

11 of 24

How I personally see DASP Top 10 now

  • Reentrancy
  • Access Control
  • Oracle manipulation
  • Math issues
    1. rounding
    2. scaling
    3. incorrect math
  • Unsafe usage of low-level code
    • delegatecall
    • call return values
    • assembly
  • Business logic bugs

12 of 24

Dynamically adapting to a changing landscape

  • Rekt
    • https://rekt.news/
  • Blockchain Threat Intelligence
    • https://blockthreat.io
  • In trend
    • bridges
  • Might be the next trend
    • L1 <-> L2 smart-contract interactions
    • configuration mistakes

13 of 24

How to increase chances of finding a bug?

  • Audits in the blockchain space are thorough and solid
    • There is an implicit assumption that an audit must find all vulnerabilities
  • Usually a project is audited multiple times by different companies
  • However, audits do not cover certain things
  • Some projects skip audits

14 of 24

The bug hunting process

15 of 24

Recon

16 of 24

Manual analysis

17 of 24

Automated analysis

18 of 24

Crafting a proof of concept

19 of 24

Where to apply this knowledge?

20 of 24

Bug bounty platforms

The bounty amounts are dynamic

The process is built on top of smart-contracts

https://hats.finance/

Traditional bug bounties for smart-contracts and blockchain systems

https://immunefi.com/

Time-framed contests

If you have reported a valid vulnerability, you will be paid

https://code4rena.com/

21 of 24

CTFs

  • Paradigm CTF

22 of 24

Other blockchains and layer 2s

  • StarkNet
    • Cairo
  • Solana
    • Rust
  • Avalanche
  • Optimism

23 of 24

Conclusion

  • The overall bug hunting process is very similar
  • The source code is usually available
    • more techniques can be applied
  • There are familiar vulnerability types
  • Even if you are not willing to learn smart-contract security you can still apply your web, application security, and cryptography knowledge and skills to hunt for bugs
  • Now you several ways to enter the blockchain security space

24 of 24

OpenZeppelin.com

forum.openzeppelin.com

docs.openzeppelin.com

Thank you!

. @_nikitastupin

/nikita-stupin-2457b1177

nikita@openzeppelin.com