TL;DR
A.S.E (AI Code Generation Security Evaluation) is a new benchmark that moves beyond "toy" code snippets to evaluate how well LLMs generate secure code within complex, real-world software repositories. The study reveals a sobering reality: even the most advanced models, including Claude 3.7 and GPT-4o, struggle with security in repository-level contexts, often prioritizing functional "correctness" over safety.
What Problem Does This Paper Address?
Most existing benchmarks for AI-generated code, like HumanEval or MBPP, focus on small, self-contained snippets. While these are great for checking if a model understands basic syntax or algorithms, they fail to capture the complexity of modern software engineering. In the real world, code lives in repositories with deep file dependencies and complex business logic.
Furthermore, existing security benchmarks often rely on "LLM-as-a-judge" or generic scanners, which can be unreliable. There is a significant gap between a model passing a unit test and a model writing code that won't lead to a SQL injection or a data breach in a production environment. The authors created A.S.E to bridge this gap by simulating the actual workflow of AI assistants (like Cursor or Claude Code) within real GitHub projects.
Methods
The researchers developed a sophisticated pipeline to ensure the benchmark is both realistic and resistant to "data leakage" (where a model simply remembers code it saw during training):
- Data Sourcing: They started with over 100,000 raw CVE (Common Vulnerabilities and Exposures) entries, narrowing them down to 40 high-quality "seed" repositories that were actively maintained and had clear vulnerability-fix patterns.
- Dual Mutation: To prevent models from simply "regurgitating" known fixes, they applied semantic mutations (renaming variables/APIs) and structural mutations (reshaping control flow and file layouts). This forces the model to actually reason about the security logic.
- Context Injection: Mimicking real AI editors, they used the BM25 algorithm to retrieve relevant context from the repository (READMEs, related source files) and provided it to the LLM.
- Custom SAST Evaluation: Instead of generic tools, they wrote 120 targeted Static Application Security Testing (SAST) rules using CodeQL and Joern. These rules are specifically calibrated to detect the exact vulnerability (e.g., a specific sink for an XSS attack) in each test case.
- Multi-dimensional Scoring: Models are graded on Security (did it fix the flaw?), Quality (is the code syntactically correct and mergeable?), and Stability (does it produce consistent results across multiple runs?).
Datasets
The primary contribution is the A.S.E Benchmark, which consists of:
- 120 repository-level instances (40 original seeds + 80 mutated variants).
- Coverage of 5 programming languages: PHP (50%), Python, Go, JavaScript, and Java.
- Focus on 4 major vulnerability types: SQL Injection (SQLi), Cross-Site Scripting (XSS), Path Traversal, and Command Injection.
Key Insights and Ideas
- The "Security-Quality Gap": There is a massive disparity between a model's ability to write working code and secure code. While top models score above 90 in Quality, their Security scores rarely break 50. Models are "eager to please" by making the code run, often at the expense of safety.
- The Reasoning Paradox: Surprisingly, "slow-thinking" or reasoning modes (like Claude-3.7-Sonnet-Thinking) sometimes performed worse in security than their "fast-thinking" counterparts. The authors suggest that increased reasoning might inadvertently lead to more complex, over-engineered code that introduces new subtle flaws.
- Path Traversal is the "Final Boss": Models performed relatively well on SQLi and XSS, but almost all struggled with Path Traversal. This suggests LLMs lack a deep understanding of file system operations and access control compared to web-based data handling.
- Open-Source is Catching Up: The gap between proprietary models (Claude, GPT) and open-source models (Qwen, DeepSeek) is narrowing significantly. Qwen3-235B, for instance, outperformed several flagship proprietary models in overall score.
Key Results
The researchers evaluated 26 mainstream LLMs. The "Leaderboard" highlights include:
- Top Performer: Claude-3.7-Sonnet took the #1 spot with an overall score of 63.01, though its security-specific score was only 46.72.
- Open-Source Hero: Qwen3-235B-Instruct ranked #3 overall (60.15), actually achieving the highest raw Security score (48.03) of any model tested.
- Stability: GPT-o3 showed incredible generation stability (98.91) but failed significantly on security (3.67), proving that a model can be very "confident" and "consistent" while being consistently wrong about security.
Limitations and Future Work
The authors acknowledge several constraints:
- Domain Scope: The benchmark is currently limited to web-related vulnerabilities. Future versions could include mobile, embedded, or blockchain-specific security tasks.
- Static vs. Dynamic: The evaluation relies on static analysis (SAST). While highly accurate for these cases, it cannot catch runtime-dependent flaws like race conditions or complex logical errors that require dynamic execution.
- Language Support: While covering five major languages, expanding to C/C++ or Rust would provide a more comprehensive view of system-level security.
- Automation of Rules: Currently, the SAST rules require expert manual calibration. The authors suggest exploring LLM-assisted generation of these security rules to scale the benchmark to newly disclosed CVEs more quickly.
Summary updated