advanced smart contract hacking - cointhinktank.com

34
#RSAC SESSION ID: Konstantinos Karagiannis Advanced Smart Contract Hacking HT-F02 CTO, Security Consulting BT @KonstantHacker

Upload: others

Post on 13-Apr-2022

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

SESSION ID:

Konstantinos Karagiannis

Advanced Smart Contract Hacking

HT-F02

CTO, Security ConsultingBT@KonstantHacker

Page 2: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

When transactions aren’t enough

2

“The key component is this idea of a Turing-complete blockchain”--Vitalik Buterin

Page 3: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Meow—putting that computing power to use?

3

Page 4: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Smart contracts

4

Page 5: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Millions of reasons to hack smart contracts

Page 6: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Problem isn’t going away

Page 7: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Solidity

Page 8: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Dev tools

.sol files > bytecode > blockchain

Atom with plugins:– language-ethereum– etheratomRemix: browser based

Page 9: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

oyente and Manticore

Page 10: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

MAIAN

Page 11: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Methodology

Interview devs

Review .sol file

Try compiling

Dissect code flow

Run oyente (cross fingers)

Run Manticore

Run MAIAN

Manually check for following vulns…

Page 12: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Reentrancy

Page 13: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Leave off the first “re-” for savings

Page 14: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Writing a contract to attack a contract

Page 15: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Reentrancy (and irony) in the dao code

Page 16: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Default public – Parity wallet hack

Page 17: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

initWallet

Page 18: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

execute

Page 19: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Parity multisig wallet hack 2

Page 20: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Parity 2 transactions

Page 21: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Not going with the (over)flow

2256 -1

Page 22: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Unchecked send in king of the ether

Page 23: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Unchecked send

Page 24: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Gas limits

Page 25: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Withdraw don’t send

Page 26: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Withdrawn not sent

Page 27: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Transaction-ordering dependence

Page 28: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Transaction-ordering dependence

Page 29: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Call-stack depth limit

Page 30: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Variable or function ambiguity

Page 31: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Odds and ends

Timestamp dependence

Business logic flaws

Encryption

Separating public/private data

Page 32: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Prepping for the future…

Page 33: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Real-time blockchain protection

Page 34: Advanced Smart Contract Hacking - cointhinktank.com

#RSAC

Get involved

34

Master Solidity

Experiment with smart contract hacking challenges online

Now that we’re done with the coin-price craze, companies are doing practical things with this technology

Enterprise Ethereum Alliance member companies are a great place to start