Enhancing Security of AI-Based Code Synthesis with GitHub Copilot via Cheap and Efficient Prompt-Engineering
Not on the map. Why?
Abstract (arXiv)
AI assistants for coding are on the rise. However one of the reasons developers and companies avoid harnessing their full potential is the questionable security of the generated code. This paper first reviews the current state-of-the-art and identifies areas for improvement on this issue. Then, we propose a systematic approach based on prompt-altering methods to achieve better code security of (even proprietary black-box) AI-based code generators such as GitHub Copilot, while minimizing the complexity of the application from the user point-of-view, the computational resources, and operational costs. In sum, we propose and evaluate three prompt altering methods: (1) scenario-specific, (2) iterative, and (3) general clause, while we discuss their combination. Contrary to the audit of code security, the latter two of the proposed methods require no expert knowledge from the user. We assess the effectiveness of the proposed methods on the GitHub Copilot using the OpenVPN project in realistic scenarios, and we demonstrate that the proposed methods reduce the number of insecure generated code samples by up to 16% and increase the number of secure code by up to 8%. Since our approach does not require access to the internals of the AI models, it can be in general applied to any AI-based code synthesizer, not only GitHub Copilot.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 11 of its 32 references that are in the map. First posted on arXiv 19 Mar 2024.
Builds on
11 of 32 references.
References · 11
- 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,878
- 2023CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Societycited by 1,348
- 2023A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPTcited by 612
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2024Data-efficient Fine-tuning for LLM-based Recommendationcited by 103
- 2022Lost at C: A User Study on the Security Implications of Large Language Model Code Assistantscited by 87
- 2022Conversing with Copilot: Exploring Prompt Engineering for Solving CS1 Problems Using Natural Languagecited by 81
- 2023On the Robustness of Code Generation Techniques: An Empirical Study on GitHub Copilotcited by 64
- 2023Small Language Models Improve Giants by Rewriting Their Outputscited by 18
Built on by
Citing papers per year: 2024: 2; 2025: 4.
6 papers.
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2025SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositoriescited by 14
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflowscited by 4
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Softwarecited by 4
- 2024Optimizing AI-Assisted Code Generationcited by 2
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practicescited by 1
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software21 Dec 2025
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practices8 Oct 2025
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflows8 Jun 2025
- 2025SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositories29 Apr 2025
- 2024Optimizing AI-Assisted Code Generation14 Dec 2024
- 2024Constrained Decoding for Secure Code Generation30 Apr 2024