All Projects → Messi-Q → GNNSCVulDetector

Messi-Q / GNNSCVulDetector

Licence: other
Smart Contract Vulnerability Detection Using Graph Neural Networks (IJCAI-20 Accepted)

Programming Languages

python
139335 projects - #7 most used programming language
solidity
1140 projects
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to GNNSCVulDetector

AMEVulDetector
Smart Contract Vulnerability Detection From Pure Neural Network to Interpretable Graph Feature and Expert Pattern Fusion (IJCAI-21 Accepted)
Stars: ✭ 23 (-45.24%)
Mutual labels:  smart-contracts, vulnerability-detection
GraphLIME
This is a Pytorch implementation of GraphLIME
Stars: ✭ 40 (-4.76%)
Mutual labels:  graph-neural-networks
storm-spec
Specification for Storm: L2/L3 distributed storage and messaging with economic incentivisation leveraging LNP/BP ecosystem
Stars: ✭ 62 (+47.62%)
Mutual labels:  smart-contracts
graphtrans
Representing Long-Range Context for Graph Neural Networks with Global Attention
Stars: ✭ 45 (+7.14%)
Mutual labels:  graph-neural-networks
mai-protocol
A Protocol for trading decentralized derivatives on Ethereum
Stars: ✭ 22 (-47.62%)
Mutual labels:  smart-contracts
Meta-GDN AnomalyDetection
Implementation of TheWebConf 2021 -- Few-shot Network Anomaly Detection via Cross-network Meta-learning
Stars: ✭ 22 (-47.62%)
Mutual labels:  graph-neural-networks
kleros
Kleros smart contracts
Stars: ✭ 203 (+383.33%)
Mutual labels:  smart-contracts
GNN4CD
Supervised community detection with line graph neural networks
Stars: ✭ 67 (+59.52%)
Mutual labels:  graph-neural-networks
dr checker 4 linux
Port of "DR.CHECKER : A Soundy Vulnerability Detection Tool for Linux Kernel Drivers" to Clang/LLVM 10 and Linux Kernel
Stars: ✭ 34 (-19.05%)
Mutual labels:  vulnerability-detection
move
Home of the Move programming language
Stars: ✭ 125 (+197.62%)
Mutual labels:  smart-contracts
scilla-vanilla
No description or website provided.
Stars: ✭ 20 (-52.38%)
Mutual labels:  smart-contracts
etherbrite
🗓 Clone eventbrite on Ethereum, built in Solidity, TruffleJS, Web3js and React/Redux.
Stars: ✭ 19 (-54.76%)
Mutual labels:  smart-contracts
wazuh-cloudformation
Wazuh - Amazon AWS Cloudformation
Stars: ✭ 32 (-23.81%)
Mutual labels:  vulnerability-detection
KGPool
[ACL 2021] KGPool: Dynamic Knowledge Graph Context Selection for Relation Extraction
Stars: ✭ 33 (-21.43%)
Mutual labels:  graph-neural-networks
erc1363-payable-token
Code implementation for the ERC-1363 Payable Token
Stars: ✭ 83 (+97.62%)
Mutual labels:  smart-contracts
GeometricFlux.jl
Geometric Deep Learning for Flux
Stars: ✭ 288 (+585.71%)
Mutual labels:  graph-neural-networks
contracts
The Consumer Contract Wallet
Stars: ✭ 88 (+109.52%)
Mutual labels:  smart-contracts
walklets
A lightweight implementation of Walklets from "Don't Walk Skip! Online Learning of Multi-scale Network Embeddings" (ASONAM 2017).
Stars: ✭ 94 (+123.81%)
Mutual labels:  graph-neural-networks
vulnerablecode
A free and open vulnerabilities database and the packages they impact. And the tools to aggregate and correlate these vulnerabilities. Sponsored by NLnet https://nlnet.nl/project/vulnerabilitydatabase/ for https://www.aboutcode.org/ Chat at https://gitter.im/aboutcode-org/vulnerablecode Docs at https://vulnerablecode.readthedocs.org/
Stars: ✭ 269 (+540.48%)
Mutual labels:  vulnerability-detection
TIMME
TIMME: Twitter Ideology-detection via Multi-task Multi-relational Embedding (code & data)
Stars: ✭ 57 (+35.71%)
Mutual labels:  graph-neural-networks

GNNSCVulDetector GitHub stars GitHub forks

This repo is a python implementation of smart contract vulnerability detection using graph neural networks. In this research work, we focus on detecting three types of smart contract vulnerabilities (i.e., reentrancy, timestamp dependence, and infinite loop).

Citation

Please use this citation if you want to cite our paper or codebase in your paper:

@inproceedings{zhuang2020smart,
  title={Smart Contract Vulnerability Detection using Graph Neural Network.},
  author={Zhuang, Yuan and Liu, Zhenguang and Qian, Peng and Liu, Qi and Wang, Xiang and He, Qinming},
  booktitle={IJCAI},
  pages={3283--3290},
  year={2020}
}

Requirements

Required Packages

  • python3
  • TensorFlow1.14.0 (tf2.0 is not supported)
  • keras2.2.4 with TensorFlow backend
  • sklearn for model evaluation
  • docopt as a command-line interface parser

Run the following script to install the required packages.

pip install --upgrade pip
pip install tensorflow==1.14.0
pip install keras==2.2.4
pip install scikit-learn
pip install docopt

Dataset

For each dataset, we randomly pick 80% contracts as the training set while the remainings are utilized for the testing set. In the comparison, metrics accuracy, recall, precision, and F1 score are all involved. In consideration of the distinct features of different platforms, experiments for reentrancy and timestamp dependence vulnerability are conducted on ESC (Ethereum smart contract) dataset, while infinite loop vulnerability is evaluated on VSC (Vntchain smart contract) dataset.

Smart contract source code

Ethereum smart contract

Vntchain smart contract

Here, we provide a tool for crawling the smart contract source code from Etherscan, which is developed in Aug 2018. If out of date, you can refer and make the corresponding improvements.

Dataset structure in this project

All of the smart contract source code, graph data, and training data in these folders in the following structure respectively.

${GNNSCVulDetector}
├── data
│   ├── loops
│   │   └── source_code
│   │   └── graph_data
│   ├── timestamp
│   │   └── source_code
│   │   └── graph_data
│   └── reentrancy
│       └── source_code
│       └── graph_data
├── features
    ├── loops
    ├── timestamp
    └── reentrancy
├── train_data
    ├── loops
    │   └── train.json
    │   └── vaild.json
    ├── timestamp
    │   └── train.json
    │   └── vaild.json
    └── reentrancy
        └── train.json
        └── vaild.json
      
  • data/reentrancy/source_code: This is the source code of smart contracts.
  • data/reentrancy/graph_data: This is the graph structure of smart contracts, consisting edges and nodes, which are extracted by our AutoExtractGraph.
  • graph_data/edge: It includes all edges and edge of each smart contract.
  • graph_data/node: It includes all nodes and node of each smart contract.
  • features/reentrancy: It includes all the reentrancy features of each smart contract extracted by our model.
  • train_data/reentrancy/train.json: This is the training data of all the smart contract for reentrancy.
  • train_data/reentrancy/valid.json: This is the testing data of all the smart contract for reentrancy.

Code Files

The tools and models are as follows:

${GNNSCVulDetector}
├── tools
│   ├── remove_comment.py
│   ├── construct_fragment.py
│   ├── reentrancy/AutoExtractGraph.py
│   └── reentrancy/graph2vec.py

AutoExtractGraph.py

  • All functions in the smart contract code are automatically split and stored.
  • Find the relationships between functions.
  • Extract all smart contracts source code into the corresponding contract graph consisting of nodes and edges.
python AutoExtractGraph.py

graph2vec.py

  • Feature ablation.
  • Convert contract graph into vectors.
python graph2vec.py

Running project

  • To run the program, use this command: python GNNSCModel.py.

Examples:

python GNNSCModel.py --random_seed 9930 --thresholds 0.45

Consultation

We would like to point that the data processing code is available here. If any question, please email to [email protected]. And, the code is adapted from GGNN. Technical questions can be addressed to [email protected], [email protected], [email protected].

Reference

  1. Li Y, Tarlow D, Brockschmidt M, et al. Gated graph sequence neural networks. ICLR, 2016. GGNN
  2. Qian P, Liu Z, He Q, et al. Towards automated reentrancy detection for smart contracts based on sequential models. 2020. ReChecker
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].