mlsanityData to 7 Oct 2026

Surgical Repair of Insecure Code Generation in LLMs

arXiv 2604.16697 ↗First posted 17 Apr 2026cs.CR cs.LGcited by 1

Not on the map. Why?

Abstract (arXiv)

Large language models write production code, and yet they routinely introduce well-known vulnerabilities. We show that this is not a knowledge deficit: the same models that generate insecure code, correctly identify and explain the vulnerability when asked directly, this is a gap we call the Format-Reliability Gap. Mechanistic analysis reveals the cause: security representations are encoded from the earliest layers but remain computationally inert until the final layer, where format-compliance demands compete with them. Because the failure is localized to a single layer, per-vulnerability steering vectors reduce insecure generation by up to 74% with negligible overhead. The mechanism and the fix generalize across five models, three architecture families, and six vulnerability types, suggesting insecure code generation is an interpretability problem, not a training artifact.

Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Builds on 32 of its 39 references that are in the map. First posted on arXiv 17 Apr 2026.

Builds on

32 of 39 references.

References · 32

  1. 2022Locating and Editing Factual Associations in GPTcited by 2,609
  2. 2023Sparse Autoencoders Find Highly Interpretable Features in Language Modelscited by 1,359
  3. 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,130
  4. 2024Refusal in Language Models Is Mediated by a Single Directioncited by 960
  5. 2023Steering Language Models With Activation Engineeringcited by 824
  6. 2022Discovering Latent Knowledge in Language Models Without Supervisioncited by 733
  7. 2019Designing and Interpreting Probes with Control Taskscited by 608
  8. 2023Eliciting Latent Predictions from Transformers with the Tuned Lenscited by 579
  9. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  10. 2021Causal Abstractions of Neural Networkscited by 401
  11. 2024LLMs Know More Than They Show: On the Intrinsic Representation of LLM Hallucinationscited by 230
  12. 2023How does GPT-2 compute greater-than?: Interpreting mathematical abilities in a pre-trained language modelcited by 199
20 more
  1. 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
  2. 2025Emergent Misalignment: Narrow finetuning can produce broadly misaligned LLMscited by 158
  3. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
  4. 2023Explaining grokking through circuit efficiencycited by 105
  5. 2022Lost at C: A User Study on the Security Implications of Large Language Model Code Assistantscited by 87
  6. 2025Model Organisms for Emergent Misalignmentcited by 84
  7. 2023How Secure is Code Generated by ChatGPT?cited by 77
  8. 2025Convergent Linear Representations of Emergent Misalignmentcited by 66
  9. 2025School of Reward Hacks: Hacking harmless tasks generalizes to misaligned behavior in LLMscited by 58
  10. 2025Thought Crime: Backdoors and Emergent Misalignment in Reasoning Modelscited by 57
  11. 2024Constrained Decoding for Secure Code Generationcited by 35
  12. 2024Prompting Techniques for Secure Code Generation: A Systematic Investigationcited by 33
  13. 2023DeceptPrompt: Exploiting LLM-driven Code Generation via Adversarial Natural Language Instructionscited by 31
  14. 2025Compromising Honesty and Harmlessness in Language Models via Deception Attackscited by 17
  15. 2025Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generationcited by 12
  16. 2025Emergent misalignment as prompt sensitivity: A research notecited by 5
  17. 2025The Devil in the Details: Emergent Misalignment, Format and Coherence in Open-Weights LLMscited by 4
  18. 2023Measuring the Knowledge Acquisition-Utilization Gap in Pretrained Language Modelscited by 3
  19. 2026Can Adversarial Code Comments Fool AI Security Reviewers -- Large-Scale Empirical Study of Comment-Based Attacks and Defenses Against LLM Code Analysiscited by 2
  20. 2025Even Heads Fix Odd Errors: Mechanistic Discovery and Surgical Repair in Transformer Attentioncited by 1

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 1.

1 paper.