SecureForge: Finding and Preventing Vulnerabilities in LLM-Generated Code via Prompt Optimization
Fuente:
arXiv
Gespeichert in:
| Hauptverfasser: | , , , , , , , |
|---|---|
| Format: | Preprint |
| Veröffentlicht: |
2026
|
| Schlagworte: | |
| Online-Zugang: | |
| Tags: |
Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
|
| _version_ | 1866914545929289728 |
|---|---|
| author | Liu, Houjun Einstein, Lisa Yang, John Baumann, Joachim Eddy, Duncan Manning, Christopher D. Kochenderfer, Mykel Yang, Diyi |
| author_facet | Liu, Houjun Einstein, Lisa Yang, John Baumann, Joachim Eddy, Duncan Manning, Christopher D. Kochenderfer, Mykel Yang, Diyi |
| contents | 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. |
| format | Preprint |
| id |
arxiv_https___arxiv_org_abs_2605_08382 |
| institution | arXiv |
| publishDate | 2026 |
| record_format | arxiv |
| spellingShingle | SecureForge: Finding and Preventing Vulnerabilities in LLM-Generated Code via Prompt Optimization Liu, Houjun Einstein, Lisa Yang, John Baumann, Joachim Eddy, Duncan Manning, Christopher D. Kochenderfer, Mykel Yang, Diyi Cryptography and Security Computation and Language Computers and Society 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. |
| title | SecureForge: Finding and Preventing Vulnerabilities in LLM-Generated Code via Prompt Optimization |
| topic | Cryptography and Security Computation and Language Computers and Society |
| url | https://arxiv.org/abs/2605.08382 |