English

Two Timin': Repairing Smart Contracts With A Two-Layered Approach

Cryptography and Security 2023-09-15 v1 Artificial Intelligence

Abstract

Due to the modern relevance of blockchain technology, smart contracts present both substantial risks and benefits. Vulnerabilities within them can trigger a cascade of consequences, resulting in significant losses. Many current papers primarily focus on classifying smart contracts for malicious intent, often relying on limited contract characteristics, such as bytecode or opcode. This paper proposes a novel, two-layered framework: 1) classifying and 2) directly repairing malicious contracts. Slither's vulnerability report is combined with source code and passed through a pre-trained RandomForestClassifier (RFC) and Large Language Models (LLMs), classifying and repairing each suggested vulnerability. Experiments demonstrate the effectiveness of fine-tuned and prompt-engineered LLMs. The smart contract repair models, built from pre-trained GPT-3.5-Turbo and fine-tuned Llama-2-7B models, reduced the overall vulnerability count by 97.5% and 96.7% respectively. A manual inspection of repaired contracts shows that all retain functionality, indicating that the proposed method is appropriate for automatic batch classification and repair of vulnerabilities in smart contracts.

Keywords

Cite

@article{arxiv.2309.07841,
  title  = {Two Timin': Repairing Smart Contracts With A Two-Layered Approach},
  author = {Abhinav Jain and Ehan Masud and Michelle Han and Rohan Dhillon and Sumukh Rao and Arya Joshi and Salar Cheema and Saurav Kumar},
  journal= {arXiv preprint arXiv:2309.07841},
  year   = {2023}
}

Comments

Submitted to the 2023 ICI Conference

R2 v1 2026-06-28T12:21:47.279Z