{"id":2377,"date":"2019-03-15T11:59:53","date_gmt":"2019-03-14T22:59:53","guid":{"rendered":"http:\/\/www.talkcrypto.org\/blog\/?p=2377"},"modified":"2021-06-07T12:10:52","modified_gmt":"2021-06-07T00:10:52","slug":"static-and-symbolic-analysis","status":"publish","type":"post","link":"https:\/\/www.talkcrypto.org\/blog\/2019\/03\/15\/static-and-symbolic-analysis\/","title":{"rendered":"Static and Symbolic Analysis"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Static Analysis<\/h4>\n\n\n\n<p>Static analysis can be described as a way to test code without actually executing it. The idea here is to use a computer program to analyse a program&#8217;s source code&nbsp;without running it.<\/p>\n\n\n\n<p>Static analysis has a few sub components such as Flow Analysis. This tracks how values might&nbsp;flow between the different memory relocations in a program. Tainted Flow Analysis is often referred to where untrusted input is considered tainted, eg input from a user and conversely, hardcoded values or constants are untainted.<\/p>\n\n\n\n<p>Flow Analysis can have &#8220;sensitivity&#8221; added to increase the precision and also to reduce false positives.&nbsp;It basically accounts for&nbsp;variables whose contents change, typically by using extra qualifiers.<\/p>\n\n\n\n<p>Context Sensitivity Analysis is another sub component of Static Analysis where calling other functions can cause false positives. &#8220;<em>So context sensitive analysis solves this&nbsp;problem by distinguishing call sites in some way, so&nbsp;that we don&#8217;t allow a call at one place to return it&#8217;s value to another call.&#8221;<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Symbolic Analysis<\/h4>\n\n\n\n<p>Symbolic execution aims to generalise testing so that instead of testing with actual values, tests are run with variables. The image below explains it best.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/Screen-Shot-2019-03-25-at-7.34.47-am-1024x689.png\" alt=\"\" class=\"wp-image-2378\" width=\"435\" height=\"293\" srcset=\"https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/Screen-Shot-2019-03-25-at-7.34.47-am-1024x689.png 1024w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/Screen-Shot-2019-03-25-at-7.34.47-am-300x202.png 300w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/Screen-Shot-2019-03-25-at-7.34.47-am-768x517.png 768w, https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/Screen-Shot-2019-03-25-at-7.34.47-am.png 1530w\" sizes=\"(max-width: 435px) 100vw, 435px\" \/><\/figure><\/div>\n\n\n\n<p>Concolic testing is another term often thrown in when discussing symbolic execution or symbolic analysis. The word concolic is a portmanteau of concrete and symbolic and is a hybrid software verification technique that performs symbolic execution, a classical technique that treats program variables as symbolic variables, along a concrete execution (testing on particular inputs) path.<\/p>\n\n\n\n<p>For more information, check out this <a rel=\"noreferrer noopener\" aria-label=\"Coursera course on Software Security (opens in a new tab)\" href=\"https:\/\/www.coursera.org\/lecture\/software-security\/basic-symbolic-execution-U9R38\" target=\"_blank\">Coursera course on Software Security<\/a><\/p>\n\n\n\n<p>What does this have to do with Blockchain? The main language of smart contracts in Ethereum is Solidity and the language is still relatively immature. There are a bunch of code analysers though to help find bugs in your smart contracts. The options are as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/trailofbits\/echidna\" target=\"_blank\">Echidna<\/a><ul><li>A fuzzer on EVM that also takes Solidity input<\/li><li>Able to fuzz a program with sequences of multiple transactions<\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/arxiv.org\/abs\/1802.06038\" target=\"_blank\">MAIAN<\/a><ul><li>An automatic tool that detects trace vulnerabilities (Greedy, Prodigal and Suicidal) with depth-first search of symbolic execution of multiple invocations<\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/b-mueller\/mythril\" target=\"_blank\">Mythril<\/a><ul><li>A blockchain exploration tool that indexes all contracts on the network, containing a disassembler, an ABI function detector and a control flow analyzer<\/li><li>Comes with a&nbsp;<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/hackernoon.com\/crafting-ethereum-exploits-by-laser-fire-1c9acf25af4f\" target=\"_blank\">&#8211;fire-laser option<\/a><\/li><li>Powered by&nbsp;<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/b-mueller\/laser-ethereum\" target=\"_blank\">laser-ethereum<\/a><\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/comaeio\/porosity\" target=\"_blank\">porosity<\/a><ul><li>A reverse enginering tool, a disassembler, an ABI function detector and a decompiler that also highlights vulnerabilities<\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/trailofbits\/manticore\" target=\"_blank\">Manticore<\/a><ul><li>A symbolic execution engine that can generate inputs to cover codepaths (<a href=\"https:\/\/asciinema.org\/a\/154012\">asciicast<\/a>), which also comes with a Python API<\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/arachnid\/evmdis\" target=\"_blank\">evmdis<\/a><ul><li>A disassembler for EVM code<\/li><\/ul><\/li><li><a href=\"https:\/\/github.com\/trailofbits\/ethersplay\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">ethersplay<\/a><ul><li>An EVM plugin for&nbsp;<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/binary.ninja\/\" target=\"_blank\">Binary Ninja<\/a><\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"http:\/\/securify.ch\/\" target=\"_blank\">Securify<\/a><ul><li>A tool that strives to achieve no false-negatives<\/li><li>The implementation seems not public as of now<\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/melonproject\/oyente\" target=\"_blank\">Oyente<\/a><ul><li>An automatic EVM code analyzer based on symbolic execution and&nbsp;<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/Z3Prover\/z3\" target=\"_blank\">Z3<\/a>&nbsp;SMT solver<\/li><\/ul><\/li><li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"http:\/\/dry.yoichihirai.com\/\" target=\"_blank\">Dr. Y&#8217;s Ethereum Contract Analyzer<\/a><ul><li>A symbolic executor for EVM code<\/li><\/ul><\/li><\/ul>\n\n\n\n<p>Source: <a href=\"https:\/\/github.com\/ethereum\/wiki\/wiki\/Ethereum-Virtual-Machine-(EVM)-Awesome-List\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">https:\/\/github.com\/ethereum\/wiki\/wiki\/Ethereum-Virtual-Machine-(EVM)-Awesome-List<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Static Analysis Static analysis can be described as a way<\/p>\n","protected":false},"author":1,"featured_media":2380,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2377","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blockchain"],"featured_image_urls":{"full":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false],"thumbnail":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis-150x150.jpg",150,150,true],"medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis-300x202.jpg",300,202,true],"medium_large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false],"large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false],"1536x1536":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false],"2048x2048":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false],"chromenews-featured":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false],"chromenews-large":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false],"chromenews-medium":["https:\/\/www.talkcrypto.org\/blog\/wp-content\/uploads\/2019\/03\/symbolic-analysis.jpg",300,202,false]},"author_info":{"info":["seandotau"]},"category_info":"<a href=\"https:\/\/www.talkcrypto.org\/blog\/category\/blockchain\/\" rel=\"category tag\">Blockchain<\/a>","tag_info":"Blockchain","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/comments?post=2377"}],"version-history":[{"count":4,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2377\/revisions"}],"predecessor-version":[{"id":2933,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/posts\/2377\/revisions\/2933"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media\/2380"}],"wp:attachment":[{"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/media?parent=2377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/categories?post=2377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.talkcrypto.org\/blog\/wp-json\/wp\/v2\/tags?post=2377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}