SecureForge: Finding and Preventing Vulnerabilities in LLM-Generated Code via Prompt Optimization
On the map: LLM agents and tool use → Agent threats, guardrails and governance
Abstract (arXiv)
LLM coding agents now generate code at an unprecedented scale, yet LLM-generated code introduces cybersecurity vulnerabilities into codebases without human involvement. Even when frontier models are explicitly asked to write secure production code with relevant weaknesses to avoid in context, we find that they still produce verifiable vulnerabilities on average 23% of the time across a corpus of 250 benign coding prompts. We introduce SecureForge, an automated pipeline that both audits security risks of frontier models and produces auditing-informed secure system prompts that reduce output security vulnerabilities while maintaining unit test performance. SecureForge first identifies benign prompts that produce statically detectable vulnerabilities, and then amplifies them into a large synthetic prompt corpus of diverse scenarios using a Markovian sampling technique to jointly maintain error rates and prompt diversity. This corpus is then used to iteratively optimize the system prompts to reduce output security vulnerabilities. On frontier models, SecureForge yields a statistically significant Pareto improvement in both unit test success and output security, with output vulnerabilities reduced by up to 48%. The resulting system prompts transfer zero-shot to in-the-wild coding agent prompts, without any exposure to real user prompt distributions during optimization.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 28 of its 51 references that are in the map. First posted on arXiv 8 May 2026.
Builds on
28 of 51 references.
Closest ancestors · 5
Same direction, newest first
- 2026Measuring AI Agents' Progress on Multi-Step Cyber Attack Scenarios11 Mar
- 2024RedCode: Risky Code Execution and Generation Benchmark for Code Agents12 Nov
- 2024AgentHarm: A Benchmark for Measuring Harmfulness of LLM Agents11 Oct
- 2024AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Bases17 Jul
- 2023Identifying the Risks of LM Agents with an LM-Emulated Sandbox25 Sep
Other references · 23
- 2022Training language models to follow instructions with human feedbackcited by 15,971
- 2025Qwen3 Technical Reportcited by 8,820
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2022Red Teaming Language Models with Language Modelscited by 1,026
- 2025Kimi K2: Open Agentic Intelligencecited by 567
- 2025GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learningcited by 542
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2024Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programscited by 291
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 155
11 more
- 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 138
- 2024Instruction Tuning for Secure Code Generationcited by 68
- 2024CYBERSECEVAL 3: Advancing the Evaluation of Cybersecurity Risks and Capabilities in Large Language Modelscited by 58
- 2023CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Modelscited by 55
- 2025BaxBench: Can LLMs Generate Correct and Secure Backends?cited by 41
- 2023Security Weaknesses of Copilot-Generated Code in GitHub Projects: An Empirical Studycited by 38
- 2024Gradient-Based Language Model Red Teamingcited by 34
- 2023Assessing the Security of GitHub Copilot Generated Code -- A Targeted Replication Studycited by 26
- 2024ProSec: Fortifying Code LLMs with Proactive Security Alignmentcited by 25
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 14
- 2024ASTPrompter: Preference-Aligned Automated Language Model Red-Teaming to Generate Low-Perplexity Unsafe Promptscited by 3
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMs
- 2024AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testing
- 2025A Mixture of Linear Corrections Generates Secure Code
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods
- 2026Poster: Rethinking Security in LLM Code Generation through Real-World Risk Scenarios
- 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Models
- 2025Explicit Vulnerability Generation with LLMs: An Investigation Beyond Adversarial Attacks
- 2025SEC-bench: Automated Benchmarking of LLM Agents on Real-World Software Security Tasks