Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanisms
Not on the map. Why?
Abstract (arXiv)
Large Language Models (LLMs) show remarkable capabilities in understanding natural language and generating complex code. However, as practitioners adopt CodeLLMs for increasingly critical development tasks, research reveals that these models frequently generate functionally correct yet insecure code, posing significant security risks. While multiple approaches have been proposed to improve security in AI-based code generation, combined benchmarks show these methods remain insufficient for practical use, achieving only limited improvements in both functional correctness and security. This stems from a fundamental gap in understanding the internal mechanisms of code generation and the root causes of security vulnerabilities, forcing researchers to rely on heuristics and empirical observations. In this work, we investigate the internal representation of security concepts in CodeLLMs, revealing that models are often aware of vulnerabilities as they generate insecure code. Through systematic evaluation, we demonstrate that CodeLLMs can distinguish between security subconcepts, enabling a more fine-grained analysis than prior black-box approaches. Leveraging these insights, we propose Secure Concept Steering for CodeLLMs (SCS-Code). During token generation, SCS-Code steers LLMs' internal representations toward secure and functional code output, enabling a lightweight and modular mechanism that can be integrated into existing code models. Our approach achieves superior performance compared to state-of-the-art methods across multiple secure coding benchmarks.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 33 of its 46 references that are in the map. First posted on arXiv 11 Mar 2026.
Builds on
33 of 46 references.
References · 33
- 2024The Llama 3 Herd of Modelscited by 14,192
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2013Efficient Estimation of Word Representations in Vector Spacecited by 4,346
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Mistral 7Bcited by 3,065
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Representation Engineering: A Top-Down Approach to AI Transparencycited by 1,239
- 2023Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!cited by 1,106
- 2023Steering Llama 2 via Contrastive Activation Additioncited by 1,009
- 2024Refusal in Language Models Is Mediated by a Single Directioncited by 960
- 2022Toy Models of Superpositioncited by 928
21 more
- 2023Steering Language Models With Activation Engineeringcited by 824
- 2023The Linear Representation Hypothesis and the Geometry of Large Language Modelscited by 679
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2024The Platonic Representation Hypothesiscited by 362
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 325
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2024The Geometry of Categorical and Hierarchical Concepts in Large Language Modelscited by 151
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
- 2023Can ChatGPT replace StackOverflow? A Study on Robustness and Reliability of Large Language Model Code Generationcited by 72
- 2024Instruction Tuning for Secure Code Generationcited by 63
- 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generationcited by 55
- 2023No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPTcited by 45
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2024Prompting Techniques for Secure Code Generation: A Systematic Investigationcited by 33
- 2025One-shot Optimized Steering Vectors Mediate Safety-relevant Behaviors in LLMscited by 27
- 2024PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs)cited by 17
- 2024SecCoder: Towards Generalizable and Robust Secure Code Generationcited by 13
- 2025Rethinking the Evaluation of Secure Code Generationcited by 10
Built on by
Not cited yet.