How Secure is Secure Code Generation? Adversarial Prompts Put LLM Defenses to the Test
On the map: LLM safety and security → Jailbreaking
Abstract (arXiv)
Recent secure code generation methods, using vulnerability-aware fine-tuning, prefix-tuning, and prompt optimization, claim to prevent LLMs from producing insecure code. However, their robustness under adversarial conditions remains untested, and current evaluations decouple security from functionality, potentially inflating reported gains. We present the first systematic adversarial audit of state-of-the-art secure code generation methods (SVEN, SafeCoder, PromSec). We subject them to realistic prompt perturbations such as paraphrasing, cue inversion, and context manipulation that developers might inadvertently introduce or adversaries deliberately exploit. To enable fair comparison, we evaluate all methods under consistent conditions, jointly assessing security and functionality using multiple analyzers and executable tests. Our findings reveal critical robustness gaps: static analyzers overestimate security by 7 to 21 times, with 37 to 60% of ``secure'' outputs being non-functional. Under adversarial conditions, true secure-and-functional rates collapse to 3 to 17%. Based on these findings, we propose best practices for building and evaluating robust secure code generation methods. Our code is available.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Placed in Jailbreaking, one of 12 directions in LLM safety and security. First posted on arXiv 11 Jan 2026.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2026: 3.
3 papers.
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMscited by 1
- 2026Do Not Copy/Paste: Soft Barriers for Copying in AI-Assisted Programmingcited by 0
- 2026Evaluating Inference-Time Defenses Against Package Hallucination in LLM-Generated Codecited by 0
- 2026Evaluating Inference-Time Defenses Against Package Hallucination in LLM-Generated Code23 Aug 2026
- 2026Do Not Copy/Paste: Soft Barriers for Copying in AI-Assisted Programming23 Aug 2026
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMs28 May 2026