Checking Smart Contracts with Structural Code Embedding

01/20/2020
by   Zhipeng Gao, et al.
0

Smart contracts have been increasingly used together with blockchains to automate financial and business transactions. However, many bugs and vulnerabilities have been identified in many contracts which raises serious concerns about smart contract security, not to mention that the blockchain systems on which the smart contracts are built can be buggy. Thus, there is a significant need to better maintain smart contract code and ensure its high reliability. In this paper, we propose an automated approach to learn characteristics of smart contracts in Solidity, which is useful for clone detection, bug detection and contract validation on smart contracts. Our new approach is based on word embeddings and vector space comparison. We parse smart contract code into word streams with code structural information, convert code elements (e.g., statements, functions) into numerical vectors that are supposed to encode the code syntax and semantics, and compare the similarities among the vectors encoding code and known bugs, to identify potential issues. We have implemented the approach in a prototype, named SmartEmbed. Results show that our tool can effectively identify many repetitive instances of Solidity code, where the clone ratio is around 90%. Code clones such as type-III or even type-IV semantic clones can also be detected accurately. Our tool can identify more than 1000 clone related bugs based on our bug databases efficiently and accurately. Our tool can also help to efficiently validate any given smart contract against a known set of bugs, which can help to improve the users' confidence in the reliability of the contract. The anonymous replication packages can be accessed at: https://drive.google.com/file/d/1kauLT3y2IiHPkUlVx4FSTda-dVAyL4za/view?usp=sharing, and evaluated it with more than 22,000 smart contracts collected from the Ethereum blockchain.

READ FULL TEXT
research
08/07/2020

When Deep Learning Meets Smart Contracts

Ethereum has become a widely used platform to enable secure, Blockchain-...
research
08/22/2019

SmartEmbed: A Tool for Clone and Bug Detection in Smart Contracts through Structural Code Embedding

Ethereum has become a widely used platform to enable secure, Blockchain-...
research
10/03/2020

Finding Ethereum Smart Contracts Security Issues by Comparing History Versions

Smart contracts are Turing-complete programs running on the blockchain. ...
research
05/04/2019

Domain Specific Code Smells in Smart Contracts

Smart contracts are programs running on a blockchain. They are immutable...
research
10/21/2022

An Empirical Study on Real Bug Fixes in Smart Contracts Projects

Blockchain uses cryptographic proof to replace trusted third parties to ...
research
07/14/2022

Multi: a Formal Playground for Multi-Smart Contract Interaction

Blockchains are maintained by a network of participants that run algorit...
research
06/02/2021

Phoenix: A Formally Verified Regenerating Vault

An attacker that gains access to a cryptocurrency user's private keys ca...

Please sign up or login with your details

Forgot password? Click here to reset