What is it about?
More and more developers are using AI tools like ChatGPT, Claude, Gemini and other large language models to write code, including C/C++ code. In this study, we asked ten different AI models to generate code and then checked what they produced using established security-analysis techniques. We classified the discovered security flaws using the industry-standard CWE system (Common Weakness Enumeration) and linked them to real-world vulnerability records (CVEs) to understand how serious they are. Our results show that a worrying number of security weaknesses show up in AI-generated code, even in code that looks correct and runs fine. This matters because developers often trust AI-written code without review, and vulnerable code can lead to crashes, data leaks, or exploitable security holes in real software.
Featured Image
Photo by Luke Jones on Unsplash
Why is it important?
As AI coding assistants become a routine part of software development, our findings show that developers, companies, and toolmakers should not assume AI-generated code is secure by default. By systematically mapping vulnerabilities across ten leading LLMs, this work provides a clear picture of where current AI code generators fall short on security. This information can guide safer adoption practices and help organizations build proper review processes rather than treating AI output as trustworthy out of the box.
Perspectives
We started this project because we kept seeing AI-generated code get merged into real projects without a second look at security. C and C++ leave a lot of room for subtle memory and input-handling mistakes, and we wanted hard numbers on how often today's LLMs make those mistakes. The results reinforced for us that AI is a powerful coding assistant, but rigorous security reviews are still essential before merging code into production.
Muhammad Usman Shahid
Read the Original
This page is a summary of: LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Models, March 2026, ACM (Association for Computing Machinery),
DOI: 10.1145/3748522.3780027.
You can read the full text:
Resources
LLM-CSEC, Paper Presentation
LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Models, paper presentation video explaining the work and results.
Generated Code, Dataset & Reports
GitHub repository containing the generated codes, datasets and other technical details.
Code Dataset, Hugging Face
Code generated by 10 different LLMs
Prompt Dataset, Hugging Face
Hugging Face prompt dataset
Contributors
The following have contributed to this page







