From HAL to HALT: Thwarting Skynet's Siblings in the GenAI Coding Era
This talk analyzes the security risks associated with using Generative AI tools for software development, specifically focusing on the high prevalence of vulnerabilities in AI-generated code. It highlights the danger of developer overconfidence in AI-generated outputs and the potential for AI to propagate insecure coding practices. The speaker advocates for the integration of automated security testing and supervised learning to improve the accuracy and trustworthiness of AI-assisted coding workflows.
Why Your AI Coding Assistant Is Likely Shipping Vulnerable Code
TLDR: Research presented at Black Hat 2024 confirms that popular generative AI coding assistants frequently suggest code containing critical security flaws, including injection and credential exposure. Developers show a dangerous tendency to over-trust these suggestions, often preferring insecure AI-generated snippets over safer alternatives. Pentesters should prioritize auditing AI-generated components in their targets, as these tools are effectively automating the introduction of technical debt and exploitable vulnerabilities.
Developers are currently in a gold rush for productivity, and generative AI is the primary tool driving the frenzy. The promise is simple: write code faster, offload the boilerplate, and let the model handle the heavy lifting. However, the reality of this shift is that we are effectively outsourcing our security posture to models that do not understand the concept of a secure development lifecycle. When a model is trained on millions of lines of public code, it learns the bad habits of the entire internet, including every insecure pattern, hardcoded secret, and broken authentication flow ever pushed to a public repository.
The Reality of AI-Generated Vulnerabilities
Recent research has quantified exactly how bad this problem is. Studies from institutions like NYU and Purdue have demonstrated that a significant percentage of code generated by assistants like GitHub Copilot and ChatGPT contains vulnerabilities that would make a junior developer blush. We are not talking about minor stylistic issues. We are talking about OWASP A03:2021-Injection flaws, improper certificate validation, and the exposure of sensitive information.
The core issue is that these models treat code as a language prediction task rather than a logic and security task. When you prompt an AI to "write a function to parse this CSV," it doesn't check for path traversal or buffer overflows. It predicts the next token based on the most statistically probable sequence it has seen in its training data. If that training data is polluted with insecure examples from Stack Overflow or poorly maintained GitHub projects, the model will faithfully reproduce those same vulnerabilities.
The Overconfidence Trap
Perhaps more concerning than the flawed code itself is the human element. The research shows that developers are not just using these tools; they are trusting them blindly. In controlled experiments, developers were presented with two options: a secure, manually written snippet and an insecure, AI-generated one. A alarming number of developers chose the insecure option because the AI-generated code often looks cleaner, follows modern syntax, or simply feels more "authoritative" due to the confidence with which the model presents it.
This creates a feedback loop. As developers accept these suggestions, they commit them to the codebase. These insecure patterns then become part of the training data for the next generation of models, effectively poisoning the well of future development. For a pentester, this is a massive opportunity. During your next engagement, don't just look for the developer's mistakes. Look for the AI's mistakes. If you see a complex, boilerplate-heavy function that handles input, there is a high probability it was generated by an AI and contains a classic vulnerability that the developer never bothered to audit.
Practical Implications for Pentesters
When you are performing a black-box or gray-box assessment, you should assume that any complex, non-trivial logic was likely generated by an AI. These models are particularly bad at handling edge cases in security-sensitive code. For example, if you are testing a Java application, look for CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS). AI models often suggest using basic string concatenation for outputting user input, completely ignoring the need for proper context-aware encoding.
Consider this common pattern an AI might suggest for a Java Servlet:
// AI-generated code often ignores context-aware encoding
String name = req.getParameter("name");
// Vulnerable: Direct output without sanitization
writer.println("Hello " + name);
A secure implementation would require explicit encoding, such as using the OWASP Java Encoder or similar libraries. The AI knows the library exists, but it rarely prioritizes its use unless explicitly prompted. As a researcher, your job is to identify these "AI-isms"—code that is syntactically perfect but logically dangerous.
Moving Toward Automated Fixes
The only way to scale security in an era of AI-generated code is to fight fire with fire. We need to move away from manual code reviews for every single line of code and toward automated, security-aware workflows. This means integrating static analysis tools that are specifically tuned to catch the common pitfalls of AI models. If you are building internal tools, focus on creating curated datasets for supervised learning. By training models on "good" code—code that follows secure coding standards—you can steer the output toward safer patterns.
Defenders must also implement strict guardrails. If your organization uses AI coding assistants, you should be enforcing policies that require security scanning on all generated code before it hits the main branch. Do not treat AI-generated code as "trusted" just because it came from a reputable vendor. Treat it with the same skepticism you would apply to a pull request from an unknown contributor.
The era of AI-assisted development is here to stay, but we cannot afford to let it become an era of automated vulnerability creation. If we don't start auditing the output of these models with the same rigor we apply to our own code, we are simply handing the keys to the kingdom to anyone who knows how to craft a clever prompt. Keep your eyes open, keep your scanners running, and never assume the AI knows what it is doing.
Vulnerability Classes
Attack Techniques
OWASP Categories
All Tags
Up Next From This Conference
Similar Talks

Unmasking the Snitch Puck: The Creepy IoT Surveillance Tech in the School Bathroom

Anyone Can Hack IoT: A Beginner's Guide to Hacking Your First IoT Device




