A Novel Vulnerability Scanner for Ethereum Smart Contracts Using Transformer Neural Network
This is a research project that aims to develop a vulnerability scanner for Ethereum smart contracts using transformer neural network. The project is developed by Emre Balci as a part of his master's thesis at the [Department of Computer Engineering], Bahcesehir University. Paper will be added here soon.
Introduction
Smart contracts are self-executing contracts that run on the Ethereum blockchain. They are used to automate business processes and execute transactions in a decentralized and trustless manner. However, smart contracts are susceptible to security vulnerabilities that can be exploited by attackers to steal funds or disrupt the operation of the contract.
To address this problem, the research proposes a novel vulnerability scanner for Ethereum smart contracts using transformer neural network. The scanner analyzes the source codes of the smart contract and uses a transformer neural network to detect accuracy.
Installation
To use the vulnerability scanner, you need to install the following dependencies:
- Python 3.7 or higher
- TensorFlow 2.4.1 or higher
- Truffle 5.3.2 or higher
- Solidity 0.7.6 or higher
Usage
To use the vulnerability scanner, you need to follow these steps:
- SmartContractApi.zip: This project is an upgraded version of https://github.com/hoss-green/Etherscan.Net utilizing fetch and save operations of smart contracts.
- Thesis.py: This file contains operations of MAIAN analysis execeution for each smart contract file previously fetched using Smart Contract API Project.
- MAIAN.py: It is a version of the existing MAIAN file with the addition of saving smart contract analysis results to Excel.
- MAIANResults.csv: Excel file where analysis results in MAIAN Py are exported.
- Opcode.py: In this file, source code of smart contracts are converted opcode then exported to excel.
- Evm.mapping.xlsx: Excel file with opcode equivalents of source codes.
- Opcode.xlsx: An excel file in which the hashes of the obtained smart contracts and the source codes of these smart contracts converted to opcode are matched.
The following command can be used to run the scanner:
To enhance our project and improve the security analysis of smart contracts, we have added the following two new artificial intelligence models:
-
LSTM.py: This file is developed using a Long Short-Term Memory (LSTM) based model for analyzing smart contracts. The LSTM model helps us better understand the functionality of smart contracts and detect security vulnerabilities.
-
Transformer.py: This file performs smart contract analysis using a Transformer-based model that includes advanced features such as attention mechanisms and multi-head attention. This model allows us to analyze large and complex smart contracts faster and more accurately.
Both of these models have contributed to enhancing our analysis of smart contract security, resulting in improved accuracy and processing speed.
Results
The vulnerability scanner has been tested on several smart contracts and has successfully detected vulnerabilities such as reentrancy, integer overflow, and unhandled exceptions. The results of the experiments are presented in Emre Balci's master's thesis.
Contributions
Contributions to the vulnerability scanner are welcome. If you find a bug or want to suggest an improvement, please open an issue on this GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.