ethploit from fuzzing to efficient exploit generation
play

EthPloit : From Fuzzing to Efficient Exploit Generation against - PowerPoint PPT Presentation

EthPloit : From Fuzzing to Efficient Exploit Generation against Smart Contracts Qingzhao Zhang 1,2 , Yizhuo Wang 1 , Juanru Li 1 , Siqi Ma 3 1 Shanghai Jiao Tong University , China 2 University of Michigan , America 3 Data 61, CSIRO , Australia


  1. EthPloit : From Fuzzing to Efficient Exploit Generation against Smart Contracts Qingzhao Zhang 1,2 , Yizhuo Wang 1 , Juanru Li 1 , Siqi Ma 3 1 Shanghai Jiao Tong University , China 2 University of Michigan , America 3 Data 61, CSIRO , Australia SANER ’ 20 , London ON . Canada , Febrary 21, 2020

  2. Contents Background 1 Motivation 2 EthPloit Fuzzer 3 Evaluation 4 Conclusion 5

  3. Contents Background 1 Motivation 2 EthPloit Fuzzer 3 Evaluation 4 Conclusion 5

  4. Overview of Ethereum Ethereum is the second - largest blockchain system 8 Eth In General ▪ A programmable blockchain ▪ A platform for decentralized applications . 6 Eth In Detail ▪ A transaction - based state machine ▪ The heart is Ethereum Virtual Machine ( EVM ) 5 Eth ▪ Based on Turing - complete programming language ( Solidity )

  5. Overview of Ethereum Ethereum is the second - largest blockchain system 8 Eth In General Blockchain level ▪ A programmable blockchain EVM level ▪ A platform for decentralized applications . 6 Eth Contract level In Detail ▪ A transaction - based state machine ▪ The heart is Ethereum Virtual Machine ( EVM ) 5 Eth ▪ Based on Turing - complete programming language ( Solidity )

  6. Smart Contract Contract Code External Owned Account ▪ Source code written in Solidity Address Balance ▪ Compiled by Solc to get bytecode ▪ Bytecode run on EVM Contract Account Address Balance Contract Action code storage ▪ Created by External Owned Account ▪ Executed on incoming transactions Crowdfunding Shared Games … Schemes Wallets

  7. Transaction Basic Fields Simulate a scene Balance ▪ From : Sender ’ s Address Call a function of contract ▪ To : Receiver ’ s Address ▪ Value : Amount of Currency Balance ▪ Data : Various situations storage ▪ Empty ( just transfer currency ) Run the code ▪ Init code of contract ▪ Called function with arguments Result ▪ Change the balance ▪ Update the storage EVM -- State variable

  8. Exploitation of Smart Contract Attacker What is the exploitation Balance ▪ From attacker to target contract TX n -1 ▪ A sequence of transactions TX n -2 Categories of exploitation Exploit … TX 1 According to the cause of damages : TX 0 ▪ Balance Increment ▪ Self - destruction Balance EVM storage ▪ Code Injection

  9. Exploitable Vulnerabilities Unchecked Transfer Value ▪ Misuse of this.balance ▪ Unlimited profit Vulnerable Access Control ▪ Missing & misuse of check - before sensitive operation Exposed Secret ▪ Newly identified vulnerability ▪ Previous tools cannot exploit

  10. Exploitable Vulnerabilities Unchecked Transfer Value Secret checker ▪ Misuse of this.balance ▪ Unlimited profit Vulnerable Access Control ▪ Missing & misuse of check - before sensitive operation Exposed Secret ▪ Newly identified vulnerability Secret setter ▪ Previous tools cannot exploit

  11. Exploitable Vulnerabilities Unchecked Transfer Value Secret checker ▪ Misuse of this.balance Attackers inspect the secret from ▪ Unlimited profit the data of previous transactions Vulnerable Access Control ▪ Missing & misuse of check Attackers break the secret - before sensitive operation checking to gain profit Exposed Secret ▪ Newly identified vulnerability Secret setter ▪ Previous tools cannot exploit

  12. Contents Background 1 Motivation 2 EthPloit Fuzzer 3 Evaluation 4 Conclusion 5

  13. Goal of the Work Unchecked Transfer Value Vulnerabilities Detected Vulnerable Access Control Exposed Secret Vulnerabilities Exploited Efficient Exploit Fuzzing Generation

  14. Challenges of Exploit Generation Challenge - 1 : Unsolvable Constraint < Situation in smart contract > < Previous solution > Condition restricting sensitive operations Previous tools ( e . g ., Teether, Mythril ) - Involve complicated operation like hash rely on SMT solver • Cannot solve cryptographic constraint • Ignore the runtime value - not stored in contract state

  15. Challenges of Exploit Generation Challenge - 2 : Blockchain Effects < Situation in smart contract > < Previous solution > Previous tools have difficulties on Blockchain effects of blockchain system manipulating blockchain effect : affect the execution of smart contracts • Lack of considering the syntax - E . g ., blockchain properties of blockchain properties e . g ., invalid timestamp • Ignore the possibility of call reverting , thus lose coverage e . g ., Teether , ContractFuzzer

  16. Our Solution Fuzzing EthPloit : a smart contract specific fuzzer Feedback of runtime value Record the runtime values of Indicated information : arguments and variables ▪ Execution history ▪ Create a blank seed set ▪ e . g ., the hash image ▪ Update the seed set ▪ State of the contract ▪ Use for the next generation ▪ i . e ., the state variable Manipulation of By instrumenting the execution environment blockchain execution

  17. Contents Background 1 Motivation 2 EthPloit Fuzzer 3 Evaluation 4 Conclusion 5

  18. Workflow of EthPloit 1 4 2 3 5

  19. Workflow Taint Analyzer 1 Knowledge of dependencies of modifying contract state improves fuzzing efficiency EthPloit applies static taint analysis to discover dependencies of modifying contract states : ▪ Generate control flow graph ▪ Label taint sources and sinks ▪ Perform taint propagation Extract variable - level dependencies ▪ Variable - Data Dependency ▪ Variable - Control Dependency

  20. Workflow Taint Analyzer 1 Knowledge of dependencies of modifying contract state improves fuzzing efficiency EthPloit applies static taint analysis to discover dependencies of modifying contract states : ▪ Generate control flow graph ▪ Label taint sources and sinks ▪ Perform taint propagation Extract variable - level dependencies ▪ Variable - Data Dependency ▪ Variable - Control Dependency

  21. Workflow Test Case Generator 2 Optimize the test case by analyzing how inputs affect the execution of exploits Extend in - function dependencies to Taint Relation Graph dependencies among functions ▪ Add suitable functions into a set of candidates Function Selection ▪ Select function from candidates based on probability distribution ▪ From pseudo - random generator Arguments Generation ▪ From dynamic seed set Blockchain Properties Based on Instrumented EVM Environment Generation

  22. Workflow Instrumented EVM Environment 3 EthPloit environment Three instrumentations Configure accounts ▪ Based on remix-debugger ▪ Deploy contract - For each test case ▪ Execute transaction Configure block properties ▪ Extract full execution trace - For each execution of transaction Force external calls to revert Compared to private Ethereum chain ▪ More light - weight - For each external call ▪ More flexible for configure - Revert the 2 nd execution of call

  23. Workflow Trace Analyzers 4 Coverage Guider Exploit Detector Measure the progress of exploit - Balance Increment oracle oriented fuzzing ▪ If attackers ’ balance is increased Construct feedback as rewards Self - Destruction oracle Critical instruction coverage ▪ If the opcode SELFDESTRUCTION is found Feedback construction Code Injection oracle ▪ Seed feedback ▪ If opcodes CALLCODE , DELEGATECALL are found ▪ Function distribution feedback ▪ If destination is controlled by attackers 𝑸 𝒈 = 𝒅 𝟏 + 𝑶 𝒅 𝒅 𝟐 − 𝒅 𝟏 𝑶 𝒖

  24. Workflow Feedback Handler 5 Dynamic Seed Strategy Aim to guide the test case generator to produce proper function arguments For the whole process of fuzzing For each test case ▪ Make use of connections among transactions ▪ Perform more mutation based on interesting cases ▪ Select local seeds after each execution of transaction : ▪ Select global seeds which have a ▪ Previous arguments lifetime during fuzzing one contract ▪ State variables ▪ All arguments of interesting cases ▪ I / O of complicated calls causing coverage increment ▪ Constant values

  25. Workflow of EthPloit 1 4 2 3 5

  26. Contents Background 1 Motivation 2 EthPloit Fuzzer 3 Evaluation 4 Conclusion 5

  27. Environment Totally 45,308 contracts Dataset Two 3.60 GHz Xeon CPUs with 128 GB RAM Environment ▪ Maximum test cases as 1,000 Fuzzing Configuration ▪ Maximum length as 3 for each case Teether [1] and MAIAN [2] with a timeout of 5 minutes Comparison [1] Krupp , Johannes , and Christian Rossow . " teether : Gnawing at ethereum to automatically exploit smart contracts ." 27 th { USENIX } Security Symposium ({ USENIX } Security 18). 2018. [2] Nikolić , Ivica , et al . " Finding the greedy , prodigal , and suicidal contracts at scale ." Proceedings of the 34 th Annual Computer Security Applications Conference . 2018.

  28. Evaluation of Contract Exploit EthPloit ▪ Totally generated 644 exploits ▪ No false positive , verified using real - world EVM ▪ 600 Balance Increment , 59 Self - destruction , 4 Code Injection Teether / MAIAN ▪ unable to analyze 5,123 contracts and 102 contracts ▪ Teether generated 14 false positive ▪ MAIAN cannot exploit lots of vulnerable contracts

Recommend


More recommend