skip to main content
research-article
Open Access
Artifacts Evaluated & Functional

Online detection of effectively callback free objects with applications to smart contracts

Published:27 December 2017Publication History
Skip Abstract Section

Abstract

Callbacks are essential in many programming environments, but drastically complicate program understanding and reasoning because they allow to mutate object's local states by external objects in unexpected fashions, thus breaking modularity. The famous DAO bug in the cryptocurrency framework Ethereum, employed callbacks to steal $150M. We define the notion of Effectively Callback Free (ECF) objects in order to allow callbacks without preventing modular reasoning.

An object is ECF in a given execution trace if there exists an equivalent execution trace without callbacks to this object. An object is ECF if it is ECF in every possible execution trace. We study the decidability of dynamically checking ECF in a given execution trace and statically checking if an object is ECF. We also show that dynamically checking ECF in Ethereum is feasible and can be done online. By running the history of all execution traces in Ethereum, we were able to verify that virtually all existing contract executions, excluding these of the DAO or of contracts with similar known vulnerabilities, are ECF. Finally, we show that ECF, whether it is verified dynamically or statically, enables modular reasoning about objects with encapsulated state.

Skip Supplemental Material Section

Supplemental Material

callbackfreeobjectsw.webm

webm

102.9 MB

References

  1. 2017. Validity Labs. https://validitylabs.org . [Online].Google ScholarGoogle Scholar
  2. Karim Ali and Ondřej Lhoták. 2013. Averroes: Whole-program Analysis Without the Whole Program. In Proceedings of the 27th European Conference on Object-Oriented Programming (ECOOP’13). Springer-Verlag, Berlin, Heidelberg, 378–400. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Ambisafe. 2017. Ethereum Asset Platform. https://www.ambisafe.co/ . [Online; accessed 1-July-2017].Google ScholarGoogle Scholar
  4. B9Lab. 2017. ING hack challenge. [Online].Google ScholarGoogle Scholar
  5. Anindya Banerjee and David A. Naumann. 2005. Ownership confinement ensures representation independence for objectoriented programs. J. ACM 52, 6 (2005), 894–960. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Philip A. Bernstein, Vassos Hadzilacos, and Nathan Goodman. 1987. Concurrency Control and Recovery in Database Systems. Addison-Wesley.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Karthikeyan Bhargavan, Antoine Delignat-Lavaud, Cédric Fournet, Anitha Gollamudi, Georges Gonthier, Nadim Kobeissi, Natalia Kulatova, Aseem Rastogi, Thomas Sibut-Pinote, Nikhil Swamy, and Santiago Zanella-Béguelin. 2016. Formal Verification of Smart Contracts: Short Paper. In Proceedings of the 2016 ACM Workshop on Programming Languages and Analysis for Security (PLAS ’16). ACM, New York, NY, USA, 91–96. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Bok Consulting. 2016a. The DAO ETC Drains. https://github.com/bokkypoobah/TheDAOETCDrains . [Online; accessed 2-July-2017].Google ScholarGoogle Scholar
  9. Bok Consulting. 2016b. Ethereum Network Attacker’s IP Address Is Traceable. https://www.bokconsulting.com.au/blog/ ethereum-network-attackers-ip-address-is-traceable/ . [Online; accessed 30-June-2017].Google ScholarGoogle Scholar
  10. Ahmed Bouajjani, Javier Esparza, and Oded Maler. 1997. Reachability analysis of pushdown automata: Application to model-checking. CONCUR’97: Concurrency Theory (1997), 135–150.Google ScholarGoogle Scholar
  11. Vitalik Buterin. 2016. CRITICAL UPDATE Re: DAO Vulnerability. https://blog.ethereum.org/2016/06/17/ critical-update-re-dao-vulnerability/ . [Online; accessed 2-July-2017].Google ScholarGoogle Scholar
  12. Phil Daian. 2016. (2016). http://hackingdistributed.com/2016/06/18/analysis-of-the-dao-exploit/Google ScholarGoogle Scholar
  13. Kevin Delmolino, Mitchell Arnett, Ahmed E. Kosba, Andrew Miller, and Elaine Shi. 2015. Step by Step Towards Creating a Safe Smart Contract: Lessons and Insights from a Cryptocurrency Lab. IACR Cryptology ePrint Archive 2015 (2015), 460.Google ScholarGoogle Scholar
  14. Kevin Delmolino, Mitchell Arnett, Ahmed E. Kosba, Andrew Miller, and Elaine Shi. 2016. Ethereum - Serpent Tutorial and Smart Contract Lab. https://github.com/mc2-umd/ethereumlab/blob/master/Examples/RPS_v2_new.py . [Online; accessed 2-July-2017].Google ScholarGoogle Scholar
  15. Edsger W. Dijkstra. 1976. A Discipline of Programming. Prentice-Hall.Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Ethereum Classic. 2017. Ethereum Classic. https://etcchain.com/ . [Online; accessed 2-July-2017].Google ScholarGoogle Scholar
  17. Ethereum Foundation. 2017a. Geth. https://github.com/ethereum/go-ethereum/wiki/geth . [Online; accessed 30-June-2017].Google ScholarGoogle Scholar
  18. Ethereum Foundation. 2017b. Solidity. https://solidity.readthedocs.io/en/develop/ . [Online; accessed 5-July-2017].Google ScholarGoogle Scholar
  19. Ethereum Reddit. 2016. From the MAKER DAO slack: "Today we discovered a vulnerability in the ETH token wrapper which would let anyone drain it.". https://www.reddit.com/r/ethereum/comments/4nmohu/from_the_maker_dao_slack_ today_we_discovered_a/ . [Online; accessed 2-July-2017].Google ScholarGoogle Scholar
  20. Etherscan. 2017. 0xbfBeA57d87E15529a30B6634C1C13F1A12Fa4d09. https://etherscan.io/address/ 0xbfbea57d87e15529a30b6634c1c13f1a12fa4d09 . [Online; accessed 1-July-2017].Google ScholarGoogle Scholar
  21. Jean-Christophe Filliâtre and Andrei Paskevich. 2013. Why3 — Where Programs Meet Provers. In Proceedings of the 22nd European Symposium on Programming (Lecture Notes in Computer Science), Matthias Felleisen and Philippa Gardner (Eds.), Vol. 7792. Springer, 125–128.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Alexey Gotsman and Hongseok Yang. 2011. Liveness-Preserving Atomicity Abstraction. In Automata, Languages and Programming - 38th International Colloquium, ICALP 2011, Zurich, Switzerland, July 4-8, 2011, Proceedings, Part II. 453–465. Google ScholarGoogle ScholarCross RefCross Ref
  23. C. A. R. Hoare. 1972. Proof of Correctness of Data Representations. Acta Inf. 1 (1972), 271–281.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J.E. Hopcroft, R. Motwani, and J.D. Ullman. 2006. Introduction to automata theory, languages, and computation. Addisonwesley.Google ScholarGoogle Scholar
  25. Leslie Lamport. 1978. Time, Clocks, and the Ordering of Events in a Distributed System. Commun. ACM 21, 7 (July 1978), 558–565. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. K. Rustan M. Leino. 2010. Dafny: An Automatic Program Verifier for Functional Correctness. In Logic for Programming, Artificial Intelligence, and Reasoning: 16th International Conference, LPAR-16, Dakar, Senegal, April 25–May 1, 2010, Revised Selected Papers, Edmund M. Clarke and Andrei Voronkov (Eds.). Springer, Berlin, Heidelberg, 348–370. Google ScholarGoogle ScholarCross RefCross Ref
  27. K. Rustan M. Leino and Peter Müller. 2005. Modular Verification of Static Class Invariants. In FM 2005: Formal Methods, International Symposium of Formal Methods Europe, Newcastle, UK, July 18-22, 2005, Proceedings. 26–42.Google ScholarGoogle Scholar
  28. K. Rustan M. Leino and Greg Nelson. 2002. Data Abstraction and Information Hiding. ACM Trans. Program. Lang. Syst. 24, 5 (Sept. 2002), 491–553. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Francesco Logozzo. 2009. Class Invariants As Abstract Interpretation of Trace Semantics. Comput. Lang. Syst. Struct. 35, 2 (July 2009), 100–142. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Melonport. 2017. Oyente. https://oyente.melonport.com . [Online; accessed 6-July-2017].Google ScholarGoogle Scholar
  32. Satoshi Nakamoto. 2008. Bitcoin: A peer-to-peer electronic cash system. https://bitcoin.org/bitcoin.pdf .Google ScholarGoogle Scholar
  33. Johannes Pfeffer. 2016. The rise of the Dark DAO. https://medium.com/@oaeee/the-rise-of-the-dark-dao-72b21a2212e3 . [Online; accessed 2-July-2017].Google ScholarGoogle Scholar
  34. Rob Pike. 2012. Go at Google. In Proceedings of the 3rd Annual Conference on Systems, Programming, and Applications: Software for Humanity (SPLASH ’12). ACM, New York, NY, USA, 5–6. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Ilya Sergey and Aquinas Hobor. 2017. A Concurrent Perspective on Smart Contracts. In 1st Workshop on Trusted Smart Contracts. Google ScholarGoogle ScholarCross RefCross Ref
  36. Ethereum StackExchange. 2017. Why is my node synchronization stuck/extremely slow at block 2,306,843? https://ethereum. stackexchange.com/questions/9883/why-is-my-node-synchronization-stuck-extremely-slow-at-block-2-306-843 . [Online; accessed 30-June-2017].Google ScholarGoogle Scholar
  37. Nick Szabo. 1997. Formalizing and securing relationships on public networks. First Monday 2, 9 (1997). Google ScholarGoogle ScholarCross RefCross Ref
  38. Validity Labs. 2017. Recursive call exploit. [Online].Google ScholarGoogle Scholar
  39. Peter Vessenes. 2016. More Ethereum Attacks: Race-To-Empty is the Real Deal. http://vessenes.com/ more-ethereum-attacks-race-to-empty-is-the-real-deal/ . [Online; accessed 2-July-2017].Google ScholarGoogle Scholar
  40. Gavin Wood. 2016. Ethereum: A Secure Decentralised Generalised Transaction Ledger. http://gavwood.com/paper.pdf . [Online; accessed 5-July-2017].Google ScholarGoogle Scholar

Index Terms

  1. Online detection of effectively callback free objects with applications to smart contracts

      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

      • Published in

        cover image Proceedings of the ACM on Programming Languages
        Proceedings of the ACM on Programming Languages  Volume 2, Issue POPL
        January 2018
        1961 pages
        EISSN:2475-1421
        DOI:10.1145/3177123
        Issue’s Table of Contents

        Copyright © 2017 Owner/Author

        This work is licensed under a Creative Commons Attribution International 4.0 License.

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 27 December 2017
        Published in pacmpl Volume 2, Issue POPL

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader