skip to main content

Precise static modeling of Ethereum “memory”

Published:13 November 2020Publication History
Skip Abstract Section

Abstract

Static analysis of smart contracts as-deployed on the Ethereum blockchain has received much recent attention. However, high-precision analyses currently face significant challenges when dealing with the Ethereum VM (EVM) execution model. A major such challenge is the modeling of low-level, transient “memory” (as opposed to persistent, on-blockchain “storage”) that smart contracts employ. Statically understanding the usage patterns of memory is non-trivial, due to the dynamic allocation nature of in-memory buffers. We offer an analysis that models EVM memory, recovering high-level concepts (e.g., arrays, buffers, call arguments) via deep modeling of the flow of values. Our analysis opens the door to Ethereum static analyses with drastically increased precision. One such analysis detects the extraction of ERC20 tokens by unauthorized users. For another practical vulnerability (redundant calls, possibly used as an attack vector), our memory modeling yields analysis precision of 89%, compared to 16% for a state-of-the-art tool without precise memory modeling. Additionally, precise memory modeling enables the static computation of a contract’s gas cost. This gas-cost analysis has recently been instrumental in the evaluation of the impact of the EIP-1884 repricing (in terms of gas costs) of EVM operations, leading to a reward and significant publicity from the Ethereum Foundation.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

Static analysis of smart contracts as-deployed on the Ethereum blockchain has received much recent attention. However, high-precision analyses currently face significant challenges when dealing with the EVM execution model. A major such challenge is the modeling of low-level, transient "memory" (as opposed to persistent, on-blockchain "storage") that smart contracts employ. We offer an analysis that models EVM memory, recovering high-level concepts via deep modeling of the flow of values. Our analysis opens the door to Ethereum static analyses with drastically increased precision. One such analysis detects the extraction of ERC20 tokens by unauthorized users. Another recognizes redundant calls to external contracts. Additionally, precise memory modeling enables the static computation of a contract’s gas cost that has recently been instrumental in the evaluation of the impact of the EIP-1884 repricing (in terms of gas costs) of EVM operations.

References

  1. Elvira Albert, Pablo Gordillo, Benjamin Livshits, Albert Rubio, and Ilya Sergey. 2018. EthIR: A Framework for High-Level Analysis of Ethereum Bytecode. In Automated Technology for Verification and Analysis (ATVA). Springer.Google ScholarGoogle Scholar
  2. Lexi Brent, Neville Grech, Sifis Lagouvardos, Bernhard Scholz, and Yannis Smaragdakis. 2020. Ethainter: A Smart Contract Security Analyzer for Composite Vulnerabilities. In Conf. on Programming Language Design and Implementation (PLDI). ACM.Google ScholarGoogle Scholar
  3. Lexi Brent, Anton Jurisevic, Michael Kong, Eric Liu, Francois Gauthier, Vincent Gramoli, Ralph Holz, and Bernhard Scholz. 2018. Vandal: A Scalable Security Analysis Framework for Smart Contracts. arXiv:cs.PL/ 1809.03981Google ScholarGoogle Scholar
  4. ChainSecurity. 2019. Dangerous Repeated Calls to Untrusted Contracts. https://medium.com/chainsecurity/dangerousrepeated-calls-to-untrusted-contracts-3c97d614744bGoogle ScholarGoogle Scholar
  5. ChainSecurity. 2020. Securify2. https://github.com/eth-sri/ securify2Google ScholarGoogle Scholar
  6. ConsenSys. 2020. ConsenSys Quorum. https://consensys.net/quorum/Google ScholarGoogle Scholar
  7. Dedaub. 2019. Contract Library. https://contract-library.com/Google ScholarGoogle Scholar
  8. Josselin Feist, Gustavo Greico, and Alex Groce. 2019. Slither: A Static Analysis Framework for Smart Contracts. In Proceedings of the 2Nd International Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB '19). IEEE Press, Piscataway, NJ, USA, 8-15. https://doi.org/10.1109/WETSEB. 2019.00008 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Neville Grech, Lexi Brent, Bernhard Scholz, and Yannis Smaragdakis. 2019. Gigahorse: Thorough, Declarative Decompilation of Smart Contracts. In Proceedings of the 41st International Conference on Software Engineering (ICSE '19). IEEE Press, Piscataway, NJ, USA, 1176-1186. https://doi.org/10.1109/ICSE. 2019.00120 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Neville Grech, Kyriakos Georgiou, James Pallister, Steve Kerrison, Jeremy Morse, and Kerstin Eder. 2015. Static Analysis of Energy Consumption for LLVM IR Programs. In Proceedings of the 18th International Workshop on Software and Compilers for Embedded Systems (SCOPES '15). ACM, New York, NY, USA, 12-21. https://doi.org/10.1145/2764967.2764974 Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Neville Grech, Michael Kong, Anton Jurisevic, Lexi Brent, Bernhard Scholz, and Yannis Smaragdakis. 2018. MadMax: Surviving Out-of-Gas Conditions in Ethereum Smart Contracts. Proc. ACM Programming Languages 2, OOPSLA (Nov. 2018 ).Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Jingxuan He, Mislav Balunović, Nodar Ambroladze, Petar Tsankov, and Martin Vechev. 2019. Learning to Fuzz from Symbolic Execution with Application to Smart Contracts. In Proceedings of the 2019 ACM SIGSAC Conference on Computer and Communications Security (CCS '19). ACM, New York, NY, USA, 531-548. https://doi.org/10.1145/3319535.3363230 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. E. Hildenbrandt, M. Saxena, N. Rodrigues, X. Zhu, P. Daian, D. Guth, B. Moore, D. Park, Y. Zhang, A. Stefanescu, and G. Rosu. 2018. KEVM: A Complete Formal Semantics of the Ethereum Virtual Machine. In 2018 IEEE 31st Computer Security Foundations Symposium (CSF). 204-217. https://doi.org/10.1109/CSF. 2018.00022 Google ScholarGoogle ScholarCross RefCross Ref
  14. Bo Jiang, Ye Liu, and W. K. Chan. 2018. ContractFuzzer: Fuzzing Smart Contracts for Vulnerability Detection. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering (ASE 2018 ). ACM, New York, NY, USA, 259-269. https://doi.org/10.1145/3238147.3238177 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Herbert Jordan, Bernhard Scholz, and Pavle Subotić. 2016. Souflé: On Synthesis of Program Analyzers. In Computer Aided Verification, Swarat Chaudhuri and Azadeh Farzan (Eds.). Springer International Publishing, Cham, 422-430.Google ScholarGoogle Scholar
  16. Tomasz Kolinko. 2018. Eveem/Panoramix-Showing Contract Sources since 2018. http://eveem.org/Google ScholarGoogle Scholar
  17. Aashish Kolluri, Ivica Nikolic, Ilya Sergey, Aquinas Hobor, and Prateek Saxena. 2019. Exploiting the Laws of Order in Smart Contracts. In Proceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA 2019 ). ACM, New York, NY, USA, 363-373. https://doi.org/10.1145/3293882.3330560 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Johannes Krupp and Christian Rossow. 2018. teEther: Gnawing at Ethereum to Automatically Exploit Smart Contracts. In 27th USENIX Security Symposium (USENIX Security 18). USENIX Association, Baltimore, MD, 1317-1333. https: //www.usenix.org/conference/usenixsecurity18/presentation/kruppGoogle ScholarGoogle Scholar
  19. Sifis Lagouvardos, Neville Grech, Ilias Tsatiris, and Yannis Smaragdakis. 2020. Precise Static Modeling of Ethereum "Memory" (artifact). https://doi.org/10.5281/zenodo.4059797 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Adam Levi. 2019. A Technical Analysis of the Genesis Alpha Hack. https://medium.com/daostack/a-technical-analysis-ofthe-genesis-alpha-hack-f8e34433c14bGoogle ScholarGoogle Scholar
  21. Loi Luu, Duc-Hiep Chu, Hrishi Olickel, Prateek Saxena, and Aquinas Hobor. 2016. Making Smart Contracts Smarter. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (CCS '16). ACM, New York, NY, USA, 254-269. https://doi.org/10.1145/2976749.2978309 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Anastasia Mavridou and Aron Laszka. 2018. Designing Secure Ethereum Smart Contracts: A Finite State Machine Based Approach. http://aronlaszka.com/papers/mavridou2018designing.pdfGoogle ScholarGoogle Scholar
  23. Mark Mossberg, Felipe Manzano, Eric Hennenfent, Alex Groce, Gustavo Grieco, Josselin Feist, Trent Brunson, and Artem Dinaburg. 2019. Manticore: A User-Friendly Symbolic Execution Framework for Binaries and Smart Contracts. arXiv e-prints, Article arXiv: 1907. 03890 ( Jul 2019 ), arXiv: 1907.03890 pages. arXiv:cs.SE/ 1907.03890Google ScholarGoogle Scholar
  24. Bernhard Mueller. 2018. Smashing Ethereum Smart Contracts for Fun and Real Profit. https://github.com/b-mueller/ smashing-smart-contracts/raw/master/smashing-smart-contracts-1of1.pdf The 9th annual HITB Security Conference.Google ScholarGoogle Scholar
  25. Ivica Nikolić, Aashish Kolluri, Ilya Sergey, Prateek Saxena, and Aquinas Hobor. 2018. Finding The Greedy, Prodigal, and Suicidal Contracts at Scale. In Proceedings of the 34th Annual Computer Security Applications Conference (ACSAC '18). ACM, New York, NY, USA, 653-663. https://doi.org/10.1145/3274694.3274743 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Anton Permenev, Dimitar Dimitrov, Petar Tsankov, Dana Drachsler-Cohen, and Martin Vechev. 2019. VerX: Safety Verification of Smart Contracts. https://files.sri.inf.ethz.ch/website/papers/sp20-verx.pdf.Google ScholarGoogle Scholar
  27. Yannis Smaragdakis. 2019. Next-Paradigm Programming Languages: What Will They Look like and What Changes Will They Bring?. In Proceedings of the 2019 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward! 2019 ). Association for Computing Machinery, New York, NY, USA, 187âĂŞ197. https://doi.org/10.1145/3359591.3359739 Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Martin Holst Swende. 2019. Security considerations for EIP-1884. URLomittedforanonymity,canbesearchedbasedontitleGoogle ScholarGoogle Scholar
  29. Petar Tsankov, Andrei Dan, Dana Drachsler-Cohen, Arthur Gervais, Florian Bünzli, and Martin Vechev. 2018. Securify: Practical Security Analysis of Smart Contracts. In Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security (CCS '18). ACM, New York, NY, USA, 67-82. https://doi.org/10.1145/3243734.3243780 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Various. 2015. Hyperledger âĂŞÂăOpen Source Blockchain Technologies. https://www.hyperledger.org/Google ScholarGoogle Scholar
  31. Various. 2018. Rattle-An EVM Binary Static Analysis Framework. https://github.com/trailofbits/rattleGoogle ScholarGoogle Scholar
  32. Various. 2018. TRON Decentralize The Web. https://tron.network/Google ScholarGoogle Scholar
  33. Various. 2019. GitHub-ewasm design-metering. https://github.com/ewasm/design/blob/master/metering.mdGoogle ScholarGoogle Scholar
  34. Valentin WÃijstholz and Maria Christakis. 2020. Targeted Greybox Fuzzing with Static Lookahead Analysis. In International Conference on Software Engineering (ICSE).Google ScholarGoogle Scholar

Index Terms

  1. Precise static modeling of Ethereum “memory”

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!