Abstract
AbstractThis paper shows that generic types (generics) are useful for writing more abstract and more general smart contracts, but this comes with some security risks, reporting a concrete security issue found while using generics for writing smart contracts that implement shared entities for the Hotmoka blockchain. That issue can be used to steal the remuneration of validator nodes. This paper proposes a patch based on appropriate code rewriting. Namely, smart contracts are pieces of code that are deployed and executed in the context of a blockchain infrastructure in order to automatically enforce some effects when particular events occur. The writing of smart contracts is a complex and critical activity that can benefit from the use of high-level features of programming languages, and generics is one of them. In many programming languages, such as Java, generics are implemented by erasure, i.e. replaced by their upper bound type during compilation into bytecode. This is safe at source level, since the compiler takes care of checking that types are correct, before erasure. However, the erased types of the generated bytecode are consequently weaker. In a permissionless blockchain, where every user can call the bytecode of smart contracts installed by other users, these weaker types pose a risk of attack.
Funder
Università degli Studi di Verona
Publisher
Springer Science and Business Media LLC
Subject
Computer Networks and Communications,Software
Reference30 articles.
1. Casino, F., Dasaklis, T.K., Patsakis, C.: A systematic literature review of blockchain-based applications: current status. Classif. Open Issues Telemat. Inform. 36, 55–81 (2019). https://doi.org/10.1016/j.tele.2018.11.006
2. Spoto, F.: A Java framework for smart contracts. In: 3rd Workshop on Trusted Smart Contracts (WTSC’19). Lecture Notes in Computer Science, vol. 11599, pp. 122–137. Springer, St. Kitts and Nevis (2019)
3. Spoto, F.: Enforcing determinism of Java smart contracts. In: 4th Workshop on Trusted Smart Contracts (WTSC’20). Lecture Notes in Computer Science, vol. 12063, pp. 568–583. Springer, Kota Kinabalu (2020)
4. Nakamoto, S.: Bitcoin: a Peer-to-Peer electronic cash system (2008). https://Bitcoin.org/Bitcoin.pdf.
5. Antonopoulos, A.M.: Mastering Bitcoin: Programming the Open Blockchain, 2nd edn. O’Reilly Media, Inc. (2017)