Probing the Prefill: Detecting Code Vulnerabilities via Latent Activations
Not on the map. Why?
Abstract (arXiv)
LLM-based code generation is now embedded in mission-critical pipelines, but defenses against vulnerable output remain post-hoc -- static analyzers, fine-tuned classifiers, or an LLM judge that screen completed code, ignoring the generating model's own internal state. We test a narrower, directly measurable question: when an LLM reads a piece of C/C++ code as context, do its hidden activations already carry a signal about that code's vulnerability status? We extract last prefill token activations from four LLMs (Granite-4.1-8B, Qwen3.5-9B, Qwen3.6-27B, Gemma-4-12B) across three model families and train MLP probes on these activations. We evaluate them on four function-level C/C++ benchmarks (Devign, Big-Vul, Draper VDISC, PrimeVul). Our probes achieve 41.7% average F1 using 13.4--16.0M-parameter probes -- under 0.2% of base-model size. On Devign, the best probe (Qwen3.5-9B, 68.8% F1) matches the published fine-tuned-classifier SOTA (67.9%) despite reading only a frozen, general-purpose LLM's activations; on the harder, more imbalanced benchmarks (Big-Vul, Draper VDISC, PrimeVul) probes trail SOTA substantially. This is early evidence that a coding LLM's own representation of arbitrary code is informative about that code's vulnerability status, motivating further work toward lightweight, model-native vulnerability screening.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 23 of its 33 references that are in the map. First posted on arXiv 17 Aug 2026.
Builds on
23 of 33 references.
References · 23
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
- 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 272
- 2026Gemma 4 Technical Reportcited by 259
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 139
- 2025Aegis2.0: A Diverse AI Safety Dataset and Risks Taxonomy for Alignment of LLM Guardrailscited by 132
- 2024On Prompt-Driven Safeguarding for Large Language Modelscited by 116
- 2018Automated Vulnerability Detection in Source Code Using Deep Representation Learningcited by 114
- 2024Granite Guardiancited by 25
- 2025False Sense of Security: Why Probing-based Malicious Input Detection Fails to Generalizecited by 19
- 2025Large Language Models Encode Semantics and Alignment in Linearly Separable Representationscited by 17
11 more
- 2026When Benchmarks Lie: Evaluating Malicious Prompt Classifiers Under True Distribution Shiftcited by 11
- 2026LLM Safety From Within: Detecting Harmful Content with Internal Representationscited by 11
- 2025Probing Latent Subspaces in LLM for AI Security: Identifying and Manipulating Adversarial Statescited by 9
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detectioncited by 5
- 2023Do Language Models Learn Semantics of Code? A Case Study in Vulnerability Detectioncited by 4
- 2025LPASS: Linear Probes as Stepping Stones for vulnerability detection using compressed LLMscited by 4
- 2025Leveraging VAE-Derived Latent Spaces for Enhanced Malware Detection with Machine Learning Classifierscited by 3
- 2025On Simulation-Guided LLM-based Code Generation for Safe Autonomous Driving Softwarecited by 3
- 2025Online automatic code generation for robot swarms: LLMs and self-organizing hierarchycited by 2
- 2026Minimal Prompt Perturbations Lead to Code Vulnerabilities: Prompt Fragility and Hidden-State Signals in Coding LLMscited by 2
- 2026Do All LLMs Know When They're Being Harmful? A Reproducibility Study of Latent-Space Safety Probes Across Model Familiescited by 2
Built on by
Not cited yet.