Large Language Model-Powered Smart Contract Vulnerability Detection: New Perspectives (2310.01152v2)
Abstract: This paper provides a systematic analysis of the opportunities, challenges, and potential solutions of harnessing LLMs such as GPT-4 to dig out vulnerabilities within smart contracts based on our ongoing research. For the task of smart contract vulnerability detection, achieving practical usability hinges on identifying as many true vulnerabilities as possible while minimizing the number of false positives. Nonetheless, our empirical study reveals contradictory yet interesting findings: generating more answers with higher randomness largely boosts the likelihood of producing a correct answer but inevitably leads to a higher number of false positives. To mitigate this tension, we propose an adversarial framework dubbed GPTLens that breaks the conventional one-stage detection into two synergistic stages $-$ generation and discrimination, for progressive detection and refinement, wherein the LLM plays dual roles, i.e., auditor and critic, respectively. The goal of auditor is to yield a broad spectrum of vulnerabilities with the hope of encompassing the correct answer, whereas the goal of critic that evaluates the validity of identified vulnerabilities is to minimize the number of false positives. Experimental results and illustrative examples demonstrate that auditor and critic work together harmoniously to yield pronounced improvements over the conventional one-stage detection. GPTLens is intuitive, strategic, and entirely LLM-driven without relying on specialist expertise in smart contracts, showcasing its methodical generality and potential to detect a broad spectrum of vulnerabilities. Our code is available at: https://github.com/git-disl/GPTLens.
- AlgoWriting. A simple guide to setting the gpt-3 temperature, 2020. https://algowriting.medium.com/gpt-3-temperature-setting-101-41200ff0d0be.
- Anthropic. Introducing claude. Anthropic Blog, 2022. https://www.anthropic.com/index/introducing-claude.
- Ethainter: a smart contract security analyzer for composite vulnerabilities. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 454–469, 2020.
- Vandal: A scalable security analysis framework for smart contracts. arXiv preprint arXiv:1809.03981, 2018.
- Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.
- Gift: Graph-guided feature transfer for cold-start video click-through rate prediction. In Proceedings of the 31st ACM International Conference on Information & Knowledge Management, pages 2964–2973, 2022.
- When chatgpt meets smart contract vulnerability detection: How far are we? arXiv preprint arXiv:2309.05520, 2023.
- Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021.
- Do you still need a manual smart contract audit? arXiv preprint arXiv:2306.12338, 2023.
- Slither: a static analysis framework for smart contracts. In 2019 IEEE/ACM 2nd International Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB), pages 8–15. IEEE, 2019.
- Generative adversarial nets. Advances in neural information processing systems, 27, 2014.
- Echidna: effective, usable, and fast fuzzing for smart contracts. In Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis, pages 557–560, 2020.
- J. Heller. Catch-22: a novel, volume 4. Simon and Schuster, 1999.
- Large language models for software engineering: A systematic literature review. arXiv preprint arXiv:2308.10620, 2023.
- Bert4eth: A pre-trained transformer for ethereum fraud detection. In Proceedings of the ACM Web Conference 2023, pages 2189–2197, 2023.
- Smartcondetect: Highly accurate smart contract code vulnerability detection mechanism using bert. In KDD Workshop on Programming Language Processing, 2021.
- Contractfuzzer: Fuzzing smart contracts for vulnerability detection. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pages 259–269, 2018.
- Zeus: analyzing safety of smart contracts. In Ndss, pages 1–12, 2018.
- Competition-level code generation with alphacode. Science, 378(6624):1092–1097, 2022.
- Smartdagger: a bytecode-based static analysis approach for detecting cross-contract vulnerability. In Proceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis, pages 752–764, 2022.
- Smart contract vulnerability detection: from pure neural network to interpretable graph feature and expert pattern fusion. arXiv preprint arXiv:2106.09282, 2021.
- Combining graph neural networks with expert knowledge for smart contract vulnerability detection. IEEE Transactions on Knowledge and Data Engineering, 2021.
- Manticore: A user-friendly symbolic execution framework for binaries and smart contracts. In 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE), pages 1186–1189. IEEE, 2019.
- Mythril. https://github.com/Consensys/mythril.
- OpenAI. Gpt-4 technical report, 2023. https://arxiv.org/abs/2303.08774.
- Generative agents: Interactive simulacra of human behavior. arXiv preprint arXiv:2304.03442, 2023.
- Automated program repair based on code review: How do pre-trained transformer models perform? arXiv preprint arXiv:2304.07840, 2023.
- Verx: Safety verification of smart contracts. In 2020 IEEE symposium on security and privacy (SP), pages 1661–1677. IEEE, 2020.
- Communicative agents for software development. arXiv preprint arXiv:2307.07924, 2023.
- Towards automated reentrancy detection for smart contracts based on sequential models. IEEE Access, 8:19685–19695, 2020.
- Cross-modality mutual learning for enhancing smart contract vulnerability detection on bytecode. In Proceedings of the ACM Web Conference 2023, pages 2220–2229, 2023.
- Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv preprint arXiv:1511.06434, 2015.
- Toolformer: Language models can teach themselves to use tools. arXiv preprint arXiv:2302.04761, 2023.
- Smarter contracts: Detecting vulnerabilities in smart contracts with deep transfer learning. In NDSS, 2023.
- Benchmarking language models for code syntax understanding. arXiv preprint arXiv:2210.14473, 2022.
- Verismart: A highly precise safety verifier for ethereum smart contracts. In 2020 IEEE Symposium on Security and Privacy (SP), pages 1678–1694. IEEE, 2020.
- Assbert: Active and semi-supervised bert for smart contract vulnerability detection. Journal of Information Security and Applications, 73:103423, 2023.
- Y. Sun and L. Gu. Attention-based machine learning model for smart contract vulnerability detection. In Journal of physics: conference series, volume 1820, page 012004. IOP Publishing, 2021.
- When gpt meets program analysis: Towards intelligent detection of smart contract logic vulnerabilities in gptscan. arXiv preprint arXiv:2308.03314, 2023.
- Towards safer smart contracts: A sequence learning approach to detecting security threats. arXiv preprint arXiv:1811.06632, 2018.
- Transformer-based language models for software vulnerability detection. In Proceedings of the 38th Annual Computer Security Applications Conference, pages 481–496, 2022.
- Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
- Securify: Practical security analysis of smart contracts. In Proceedings of the 2018 ACM SIGSAC conference on computer and communications security, pages 67–82, 2018.
- N. vulnerability database. Common vulnerabilities and exposures (cves). https://cve.mitre.org/index.html.
- Codet5+: Open code large language models for code understanding and generation. arXiv preprint arXiv:2305.07922, 2023.
- Chain-of-thought prompting elicits reasoning in large language models. Advances in Neural Information Processing Systems, 35:24824–24837, 2022.
- D. Wong and M. Hemmel. Decentralized application security project top 10 of 2018, 2018.
- How effective are neural networks for fixing security vulnerabilities. arXiv preprint arXiv:2305.18607, 2023.
- V. Wüstholz and M. Christakis. Harvey: A greybox fuzzer for smart contracts. In Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pages 1398–1409, 2020.
- The rise and potential of large language model based agents: A survey. arXiv preprint arXiv:2309.07864, 2023.
- Automated program repair in the era of large pre-trained language models. In Proceedings of the 45th International Conference on Software Engineering (ICSE 2023). Association for Computing Machinery, 2023.
- xfuzz: Machine learning guided cross-contract fuzzing. IEEE Transactions on Dependable and Secure Computing, 2022.
- Tree of thoughts: Deliberate problem solving with large language models. arXiv preprint arXiv:2305.10601, 2023.
- Mpro: Combining static and symbolic analysis for scalable testing of smart contract. In 2019 IEEE 30th International Symposium on Software Reliability Engineering (ISSRE), pages 456–462. IEEE, 2019.
- Cumulative reasoning with large language models. arXiv preprint arXiv:2308.04371, 2023.
- Demystifying exploitable bugs in smart contracts. ICSE, 2023.
- A survey of large language models. arXiv preprint arXiv:2303.18223, 2023.
- Sok: Decentralized finance (defi) attacks. In 2023 IEEE Symposium on Security and Privacy (SP), pages 2444–2461. IEEE, 2023.
- Smart contract vulnerability detection using graph neural networks. In Proceedings of the Twenty-Ninth International Conference on International Joint Conferences on Artificial Intelligence, pages 3283–3290, 2021.