mlsanityData to 14 Oct 2026

Efficient Avoidance of Vulnerabilities in Auto-completed Smart Contract Code Using Vulnerability-constrained Decoding

arXiv 2309.09826 ↗First posted 18 Sep 2023cs.CR cs.AI cs.CLcited by 14

Not on the map. Why?

Abstract (arXiv)

Auto-completing code enables developers to speed up coding significantly. Recent advances in transformer-based large language model (LLM) technologies have been applied to code synthesis. However, studies show that many of such synthesized codes contain vulnerabilities. We propose a novel vulnerability-constrained decoding approach to reduce the amount of vulnerable code generated by such models. Using a small dataset of labeled vulnerable lines of code, we fine-tune an LLM to include vulnerability labels when generating code, acting as an embedded classifier. Then, during decoding, we deny the model to generate these labels to avoid generating vulnerable code. To evaluate the method, we chose to automatically complete Ethereum Blockchain smart contracts (SCs) as the case study due to the strict requirements of SC security. We first fine-tuned the 6-billion-parameter GPT-J model using 186,397 Ethereum SCs after removing the duplication from 2,217,692 SCs. The fine-tuning took more than one week using ten GPUs. The results showed that our fine-tuned model could synthesize SCs with an average BLEU (BiLingual Evaluation Understudy) score of 0.557. However, many codes in the auto-completed SCs were vulnerable. Using the code before the vulnerable line of 176 SCs containing different types of vulnerabilities to auto-complete the code, we found that more than 70% of the auto-completed codes were insecure. Thus, we further fine-tuned the model on other 941 vulnerable SCs containing the same types of vulnerabilities and applied vulnerability-constrained decoding. The fine-tuning took only one hour with four GPUs. We then auto-completed the 176 SCs again and found that our approach could identify 62% of the code to be generated as vulnerable and avoid generating 67% of them, indicating the approach could efficiently and effectively avoid vulnerabilities in the auto-completed code.

Key facts. Cited by 14 papers in the map (data through 14 Oct 2026). Builds on 26 of its 44 references that are in the map. First posted on arXiv 18 Sep 2023.

Builds on

26 of 44 references.

References · 26

  1. 2022Training language models to follow instructions with human feedbackcited by 15,971
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  3. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
  4. 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,411
  5. 2018Deep contextualized word representationscited by 2,290
  6. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
  7. 2021Offline Reinforcement Learning as One Big Sequence Modeling Problemcited by 644
  8. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
  9. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
  10. 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 358
  11. 2018code2vec: Learning Distributed Representations of Codecited by 250
  12. 2017Lexically Constrained Decoding for Sequence Generation Using Grid Beam Searchcited by 237
14 more
  1. 2017Beam Search Strategies for Neural Machine Translationcited by 232
  2. 2018Fast Lexically Constrained Decoding with Dynamic Beam Allocation for Neural Machine Translationcited by 182
  3. 2018The Adverse Effects of Code Duplication in Machine Learning Models of Codecited by 126
  4. 2023Execution-based Code Generation using Deep Reinforcement Learningcited by 99
  5. 2019Slither: A Static Analysis Framework For Smart Contractscited by 89
  6. 2023How Secure is Code Generated by ChatGPT?cited by 81
  7. 2022PanGu-Coder: Program Synthesis with Function-Level Language Modelingcited by 48
  8. 2019Empirical Review of Automated Analysis Tools on 47,587 Ethereum Smart Contractscited by 36
  9. 2023Beyond the Safeguards: Exploring the Security Risks of ChatGPTcited by 36
  10. 2018ContractFuzzer: Fuzzing Smart Contracts for Vulnerability Detectioncited by 32
  11. 2020How Effective are Smart Contract Analysis Tools? Evaluating Smart Contract Static Analysis Tools Using Bug Injectioncited by 20
  12. 2020sFuzz: An Efficient Adaptive Fuzzer for Solidity Smart Contractscited by 19
  13. 2021Detecting Gender Bias in Transformer-based Models: A Case Study on BERTcited by 8
  14. 2022Secure-by-Construction Synthesis of Cyber-Physical Systemscited by 1

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 6; 2025: 6; 2026: 2.

14 papers.

Sort:

By area: