Bugs in the Blockchain and “Contractual” Vulnerability

Slides:



Advertisements
Similar presentations
Bitcoin: A New Internet Currency Stephen Clayton Senior Economic Education Specialist Federal Reserve Bank of Dallas The opinions expressed are solely.
Advertisements

Beyond Bitoin: The Bitcoin 2.0 movement
BITCOIN An introduction to a decentralised and anonymous currency. By Andy Brodie.
1 Bitcoin A Digital Currency. Functions of Money.
Blockchain The Ethereum World Computer – Individual Empowerment or the first step to even more information control?
Intro to Block Chain Bitcoin. Blocks ●Ethereum - block chain ●Dogecoin - block chain ●Ripple - not a block chain ●Stellar - not a block chain ●Bitcoin.
© 2016 consensys.net Intro to The Blockchain. © 2016 consensys.net.
Block Chain 101 May 2017.
Motivation ✓ ✘ ? Bitcoin/Ideal Credit Card Works on Internet
BlockChain Technology
Blockchain Infrastructure for e-Science
Cryptocurrencies by.
Blockchain Introduction
Bitcoin - a distributed virtual currency system
Where Money and Technology Meet
KrypC Technologies Accelerated Blockchain Adoption.
Distributed Systems for Information Systems Management
Cryptocurrencies By Rui Sakurai and Shane Spears
Introduction to Blockchain & Ethereum
DAO for penetration testers
Blockchains and Cryptocurrencies: What Financial Planners Need to Know
The Cryptoeconomic Way
Blockchain at UB B. Ramamurthy
So what is Blockchain anyway?
Blockchain Adrian Zaragoza.
“The blockchain is the most important technology since the internet itself.” Mark Andreessen: Cofounder of Netscape; board of directors of: Facebook,
Deanonymization of Clients in Bitcoin P2P Network

Technical Overview of Bitcoin
Strategizing Testing for Blockchain /Distributed Ledger Products
Rechtsanwältin – Germany Attorney at Law – New York
Duke University and NBER
Blockchain and Cryptocurrencies
Getting Started with Ethereum Private Blockchain
Introdaction in Ethereum blockchain and Smart contract
BLOCKCHAIN BASICS & LEGAL ISSUES
The Pentester’s View on Blockchain Projects
XinFin Blockchain for global Trade and Finance
Bitcoin: A New Internet Currency
Blockchains (2) slides have been taken from:
Blockchain technology
Distributed Ledger Technology (DLT) and Blockchain
Blockchain Alexander Prenta 9/27/2018.
Nonce Making Sense of Nonces.
How to Hack a Cryptocurrency
Introduction to Blockchain
Blockchain Concepts RISK FORUM 2017 Hash function (e.g. SHA-256)
Swagatika (Jazz) Sarangi
Bitcoin & Blockchain Bina Ramamurthy 2/22/2019.
OurSQL = MySQL + Blockchain
GRIF DEX is an international decentralized exchange, a trading platform where you can buy and sell coins, tokens and fiat currency. An exchange will conform.
Debasis Bhattacharya, JD, DBA – UH Maui College, HI
FST Network All Rights Reserved
A Conceptual Model for Ethereum Blockchain Analytics
Presentation On Bit-Coins.
Blockchains and Auditing
Blockchains and Smart Contracts for the Internet of Things
Ethereum Virtual Machine
Analysing Vulnerabilities in Smart Contracts
— The Blockchain Innovation Hub
Wokshop SAIS 2018 Dr. Meg Murray Kennesaw state university
Faculty Seminar Series Blockchain Technology
Swagatika (Jazz) Sarangi
Campbell R. Harvey Duke University and NBER
Duke University and NBER
Blockchain Tech Big Picture
Campbell R. Harvey Duke University and NBER
Blockchain Tech Big Picture
Explore Txs, block, blockchain in Bitcoin
Presentation transcript:

Bugs in the Blockchain and “Contractual” Vulnerability Stark Riedesel

Image source: https://davidgerard. co

Overview Define Blockchain Define Smart Contract Apply AppSec

What’s a Blockchain? A (write-once) database with state changes Coin moves from owner A to owner B Balance of wallet A changes from X to Y Coin XYZ was created and debited to owner A Coin XYZ was destroyed by owner A Data stored at Z location has been changed to X Event A has been triggered with data X, Y, and Z Similar to git, users maintain a full history History is independently verifiable P2P Message passing (RPC) Image source: https://github.com/ethereum/wiki/wiki/White-Paper

Source: https://github.com/ethereum/wiki/wiki/White-Paper

Why is it “Secure”? Immutability Proof of Work (PoW) aka. Mining SHA/Scrypt/Ethash/Equihash/etc… Hash of previous block + Timestamp Proof of Work (PoW) aka. Mining Computationally intensive Ensures history cannot change Adjustable “Difficulty” Hard to compute <-> Easy to check Decentralization All nodes have same data - “Public Ledger” Each (full) node verifies complete history Uses established public-key algorithms (ex. ECDSA) Image source: https://github.com/ethereum/wiki/wiki/White-Paper

What does the blockchain Look Like? https://blockchain.info/ https://etherscan.io/

Types of Blockchains Public Chains Private Chains Quorum Bitcoin (currency BTC) The “original” and largest ($250b mkt cap) Ethereum (currency ETH) The “original” smart contracting ledger Monero (currency XMR) Private transactions on a public chain Ripple (currency XRP) Bank-to-Bank settlements platform Cardano (currency ADA) Proof-of-Stake (not yet deployed) Quorum JPMC fork of Ethereum for permissioned chains Proof-of-Authority (PoA) Chain code uses EVM (Ethereum virtual machine) Hyper Ledger Fabric Permissioned chain for generic state changes Chain code (usually) written in Go State database usually CouchBase (JSON support)

Attacks on the Chain Double Spend - Sybil attack (51% attack) Longest chain is the most trusted chain Attacker creates longer chain by mining faster than the rest of the network Attacker slows/prevents block relaying Protected by block rewards incentivizing mining Mining “pools” exacerbate issue Small chains especially vulnerable

Extending the Blockchain Embed “code” within a transaction Application state  Blockchain state Database contains: Contracts (addresses mapped to chain code) Contract storage (sparse hash map of memory address to value) Balance sheet (addresses mapped to value) Code is immutable Code defines how state can change Transactions “call” contract functions Fully decentralized web applications (web3.0) Ethereum contracts provide application logic Geth/Parity node runs on client Web3.js communicates with Geth to query state and send transactions https://metamask.io/

Smart Contract Use Cases Tokens (ICO fundraising) Prediction Markets Online gaming Trade settlements (financial services) Legal contracting (ex. insurance) Licensing (ex. copywrites, patents, software licenses) Decentralized Autonomous Organizations (DAO)

What Does a Contract Look like? Solidity http://truffleframework.com/boxes/metacoin

What Does a Contract Look like? EVM Bytecode http://truffleframework.com/boxes/metacoin

Smart Contract Weaknesses Secrecy is hard Everything is public by design Contract code & storage Transaction contents Private modifier does nothing for secrecy

Smart Contract Weaknesses AuthZ is hard Public blockchains means anyone can call your functions Each function must explicitly check for auth Internal functions must be marked “internal”

Smart Contract Weaknesses Integers are hard 0 – 1 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF Very common vuln Can lead to buffer overruns (array length underflow) Use SafeMath

Smart Contract Weaknesses Concurrency is hard Order of operations matter Revert only undoes your own state Sending transactions can have side-effects Sending ETH can invoke a receiving function (reentrancy bugs)

Smart Contract Weaknesses Randomness is hard All nodes in the chain must agree on computation Poor sources of entropy in chain

Tools for the Smart Contracting Truffle: development build framework Ganache: CLI/GUI fake blockchain for testing/development (instant mining, now PoW) Geth: Official Ethereum client written in Go (most common) Parity: Ethereum client written in Rust (second most common) Solc: Solidity compiler Mist: Official Ethereum web browser (built-in Ethereum client and web3 engine) Metamask: Chrome/Firefox extension for connecting to Ethereum networks Porosity: Ethereum decompiler/disassembler Solhint: Solidity linter and static code analysis Mythril: Ethereum contract search tool and static analysis engine DappHub: Collection of useful utilities for developing, testing, and hacking on Ethereum https://github.com/starkriedesel/BlockchainToolbox

Image Source: https://congacomic.tumblr.com/ Questions?