Not Your Grandmas Smart Contract Verification Florian Hubert Dana - - PowerPoint PPT Presentation

not your grandma s smart contract verification
SMART_READER_LITE
LIVE PREVIEW

Not Your Grandmas Smart Contract Verification Florian Hubert Dana - - PowerPoint PPT Presentation

Not Your Grandmas Smart Contract Verification Florian Hubert Dana Drachsler- Andrei Arthur Quentin Petar Martin Buenzli Ritzdorf Cohen Dan Gervais Hibon Tsankov Vechev http://blockchainsecurity.ethz.ch Smart Contract Security


slide-1
SLIDE 1

Not Your Grandma’s Smart Contract Verification

Florian Buenzli Dana Drachsler- Cohen Andrei Dan Arthur Gervais Hubert Ritzdorf Petar Tsankov Martin Vechev Quentin Hibon

http://blockchainsecurity.ethz.ch

slide-2
SLIDE 2

Smart Contract Security Bugs in the News

slide-3
SLIDE 3

Unpri rivileged write to storage

address owner = ...; function initWallet(address _owner) {

  • wner = _owner;

} function withdraw(uint amount) { if (msg.sender == owner) {

  • wner.transfer(amount);

} }

Wallet Contract Any user may change the wallet’s owner Only owner can send ether

An attacker used a similar bug to steal $30M in July

slide-4
SLIDE 4

More Security Bugs…

Unexpected ether flows

slide-5
SLIDE 5

More Security Bugs…

Insecure coding, such as unprivileged writes (e.g., Multisig Parity bug) Unexpected ether flows

slide-6
SLIDE 6

More Security Bugs…

Insecure coding, such as unprivileged writes (e.g., Multisig Parity bug) Unexpected ether flows Use of unsafe inputs (e.g., reflection, hashing, …)

slide-7
SLIDE 7

More Security Bugs…

Reentrant method calls (e.g., DAO bug) Insecure coding, such as unprivileged writes (e.g., Multisig Parity bug) Unexpected ether flows Use of unsafe inputs (e.g., reflection, hashing, …)

slide-8
SLIDE 8

More Security Bugs…

Manipulating ether flows via transaction reordering Reentrant method calls (e.g., DAO bug) Insecure coding, such as unprivileged writes (e.g., Multisig Parity bug) Unexpected ether flows Use of unsafe inputs (e.g., reflection, hashing, …)

slide-9
SLIDE 9

Transaction re reordering

uint price = 10; address owner; function setPrice(uint newPrice) { if (msg.sender == owner) price = newPrice; } function sellToken() { msg.sender.transfer(price); }

Token Contract The owner can change the price A user can buy with the current price

The two operations do not commute

slide-10
SLIDE 10

Automated Security Analysis

slide-11
SLIDE 11

Automated Security Analysis Approaches

All possible contract behaviors Security Bugs

Problem: Cannot enumerate all possible contract behaviors…

slide-12
SLIDE 12

Security Analysis Approaches

Testing Dynamic (symbolic) analysis Automated verification

Report true bugs Can miss bugs Can report false alarms No missed bugs Report true bugs Can miss bugs

slide-13
SLIDE 13

Current State of Automated Analysis for Ethereum Smart Contracts

slide-14
SLIDE 14

Security Analysis Approaches

Testing Dynamic (symbolic) analysis Automated verification

Report true bugs Can miss bugs Can report false alarms No missed bugs Report true bugs Can miss bugs

Populus Oyente

slide-15
SLIDE 15

Fully automated, one-click, formal verification system for Ethereum smart contracts

www.securify.ch

slide-16
SLIDE 16

Demo

slide-17
SLIDE 17

Securify: Under the Hood

Securify Report

Static Analysis Decomp. Infer

Securify Intermediate Representation

00: x = Balance 02: y = 0x20 04: If (x == 0x00) 06: MStore(y, x) 08: z = y 0a: goto 0x42 ⋮

Securify Semantic Representation

MemTag(0x20, Balance) MemTag(0x40, Const) VarTag(z, Const) VarTag(k, Gas) Assign(s, 0x20) Call(s{0x20}, k{Gas}) ⋮

EVM Binary

00: 60 02: 5b 04: 42 06: 80 08: 90 0a: 56 ⋮

Security patterns expressed in a designated security language

Fully automated, easily extensible

Captures key semantic facts about the contract

slide-18
SLIDE 18

ChainSecurity

Swiss-based startup that provides intelligent security solutions for blockchains and smart contracts https://chainsecurity.com

Automated Security Analysis Systems Comprehensive Smart Contract Auditing

slide-19
SLIDE 19

Summary

https://www.securify.ch

contact@chainsecurity.com @chain_security

Get in touch with our team

  • f security / blockchain /

program analysis experts

https://chainsecurity.com

Product Research

Fully automated Strong guarantees Extensible