mlsanityData to 14 Oct 2026

A Mixture of Linear Corrections Generates Secure Code

arXiv 2507.09508 ↗First posted 13 Jul 2025cs.CR cs.AIcited by 4

Not on the map. Why?

Abstract (arXiv)

Large language models (LLMs) have become proficient at sophisticated code-generation tasks, yet remain ineffective at reliably detecting or avoiding code vulnerabilities. Does this deficiency stem from insufficient learning about code vulnerabilities, or is it merely a result of ineffective prompting? Using representation engineering techniques, we investigate whether LLMs internally encode the concepts necessary to identify code vulnerabilities. We find that current LLMs encode precise internal representations that distinguish vulnerable from secure code--achieving greater accuracy than standard prompting approaches. Leveraging these vulnerability-sensitive representations, we develop an inference-time steering technique that subtly modulates the model's token-generation probabilities through a mixture of corrections (MoC). Our method effectively guides LLMs to produce less vulnerable code without compromising functionality, demonstrating a practical approach to controlled vulnerability management in generated code. Notably, MoC enhances the security ratio of Qwen2.5-Coder-7B by 8.9%, while simultaneously improving functionality on HumanEval pass@1 by 2.1%.

Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 33 of its 42 references that are in the map. First posted on arXiv 13 Jul 2025.

Builds on

33 of 42 references.

References · 33

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  2. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  3. 2022Solving Quantitative Reasoning Problems with Language Modelscited by 1,392
  4. 2016Understanding intermediate layers using linear classifier probescited by 1,353
  5. 2023Representation Engineering: A Top-Down Approach to AI Transparencycited by 1,336
  6. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  7. 2023Steering Llama 2 via Contrastive Activation Additioncited by 1,085
  8. 2023The Internal State of an LLM Knows When It's Lyingcited by 659
  9. 2024A Survey on Large Language Models for Code Generationcited by 658
  10. 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 546
  11. 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
  12. 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 272
21 more
  1. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 155
  2. 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 139
  3. 2024Personalized Steering of Large Language Models: Versatile Steering Vectors Through Bi-directional Preference Optimizationcited by 118
  4. 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 97
  5. 2024Adaptive Activation Steering: A Tuning-Free LLM Truthfulness Improvement Method for Diverse Hallucinations Categoriescited by 77
  6. 2024Instruction Tuning for Secure Code Generationcited by 68
  7. 2024Vul-RAG: Enhancing LLM-based Vulnerability Detection via Knowledge-level RAGcited by 68
  8. 2023Understanding the Effectiveness of Large Language Models in Detecting Security Vulnerabilitiescited by 59
  9. 2024LLM4Vuln: A Unified Evaluation Framework for Decoupling and Enhancing LLMs' Vulnerability Reasoningcited by 59
  10. 2024Controllable Text Generation for Large Language Models: A Surveycited by 57
  11. 2024Large Language Model for Vulnerability Detection: Emerging Results and Future Directionscited by 45
  12. 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
  13. 2025Taxonomy, Opportunities, and Challenges of Representation Engineering for Large Language Modelscited by 34
  14. 2024Generalization-Enhanced Code Vulnerability Detection via Multi-Task Instruction Fine-Tuningcited by 30
  15. 2024ProSec: Fortifying Code LLMs with Proactive Security Alignmentcited by 25
  16. 2024Learning Code Preference via Synthetic Evolutioncited by 19
  17. 2024Towards Inference-time Category-wise Safety Steering for Large Language Modelscited by 18
  18. 2024Security Vulnerability Detection with Multitask Self-Instructed Fine-Tuning of Large Language Modelscited by 14
  19. 2024DocCGen: Document-based Controlled Code Generationcited by 11
  20. 2024INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulnesscited by 8
  21. 2024APILOT: Navigating Large Language Models to Generate Secure Code by Sidestepping Outdated API Pitfallscited by 3

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 2; 2026: 2.

4 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanisms
  2. 2026Surgical Repair of Insecure Code Generation in LLMs
  3. 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMs
  4. 2025Explicit Vulnerability Generation with LLMs: An Investigation Beyond Adversarial Attacks
  5. 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
  6. 2026Enhancing Reliability in LLM-Based Secure Code Generation
  7. 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods
  8. 2026Poster: Rethinking Security in LLM Code Generation through Real-World Risk Scenarios