TL;DR
AI coding agents are becoming incredibly proficient at writing functional code, but they are alarmingly bad at making it secure. The new Last Secure Code Benchmark (LSCBench) reveals that while top-tier agents can fulfill functional requirements over 90% of the time, even the best model produces code that is both functional and secure in only 25.1% of cases.
What Problem Does This Paper Address?
We are entering the era of "vibe coding," where developers describe what a program should do in plain English and let AI agents handle the implementation. While this is great for productivity, it creates a massive security blind spot. Users typically test if the code works (functionality) but rarely audit it for vulnerabilities.
Existing benchmarks for AI code security often fall short because they focus on a single programming language, a narrow set of vulnerability types, or only evaluate small snippets of code. The authors of this paper argue that we need a more rigorous, multi-dimensional way to test if AI agents can implicitly handle security decisions—like sanitizing inputs or enforcing access boundaries—without being explicitly told to do so.
Methods
The researchers developed a robust pipeline to turn real-world vulnerabilities into 450 distinct coding tasks.
- Sourcing: They pulled 150 scenarios from real-world CVEs and expert-crafted Java vulnerabilities.
- Three Granularities: To see how scope affects security, they cut each scenario into three task levels:
- Function: Filling in a specific masked function.
- File: Recreating entire source files.
- Repository: Rebuilding a declared source tree from scratch.
- Neutral Specs: Crucially, the prompts given to the AI agents describe only functionality and never mention security. This mimics the real-world "vibe coding" workflow.
- Rigorous Grading: Every agent submission is run through two hidden test suites: one for functionality and one for security (using proof-of-concept attacks).
Datasets
The primary contribution is LSCBench, which features:
- 150 scenarios branched into 450 tasks.
- 7 languages: Java, C, C++, JavaScript, Python, PHP, and Go.
- 24 CWE categories: Covering 21 of the 2025 MITRE Top 25 most dangerous software weaknesses.
The dataset is balanced to prioritize the most severe weakness classes for each specific language (e.g., memory safety for C/C++, injection for PHP).
Key Insights and Ideas
- The Functionality-Security Gap: There is a massive "silent failure" mode where code passes all functional tests but remains wide open to exploits. Users who "vibe" and move on are likely shipping vulnerable code.
- The Granularity Paradox: You might expect security to drop as the task gets harder (Repo level), but the opposite is often true. At the "Function" level, agents are often "invited" by the surrounding code structure to reproduce the original vulnerable implementation. At the "Repo" level, agents have more freedom to design the module securely from the ground up.
- Security is a Choice, Not a Phase: The data shows that secure solutions don't take more "turns" (steps) than vulnerable ones. Security isn't an extra layer added at the end; it's a fundamental choice made during the initial writing process.
- The "Unstated Policy" Wall: Agents are decent at "local" security checks (like bounds checking in C). However, they almost completely fail at vulnerabilities that depend on unstated organizational policies, such as Server-Side Request Forgery (SSRF) or Information Exposure.
Key Results
The researchers evaluated six frontier models, including Claude Fable 5, GPT-5.6-Sol, and Qwen3.8-Max.
- High Functionality: Most models passed the functional suite on 87% to 91% of tasks.
- Low Security: The joint pass rate (Functional AND Secure) peaked at just 25.1% (Claude Fable 5).
- Inconsistency: Only 12% of scenarios were secured by the best model across all three granularities (Function, File, and Repo).
- The "Reminder" Boost: Adding a simple sentence—"Please make sure your implementation... is secure"—improved the joint pass rate by 15 to 21 points for most models. However, even with the reminder, more than half of the tasks remained insecure.
Limitations and Future Work
While LSCBench is comprehensive, the authors note a few areas for growth:
- Human-in-the-loop: The benchmark evaluates autonomous agents. Future work could explore how human intervention during the "vibe" process changes security outcomes.
- Iterative Refinement: The current study focuses on the first attempt (pass@1). Exploring how agents respond to security-specific feedback or automated scanning tools would be a natural next step.
- Threat Modeling: The authors suggest that closing the security gap will require training agents to explicitly reason about threat models rather than just optimizing for passing functional test cases.
Summary updated