cs.CROct 19, 2026

When Models Know but Can't Linearly Say: Relational Encoding Limits Linear Vulnerability Classification in Code LLMs

Authors: Rui Melo, Andre Catarino, Claudia Mamede, Corina Pasareanu, Rui Abreu

Organizations: Carnegie Mellon University, Pittsburgh, PA, USA · Faculty of Engineering, University of Porto, Portugal

Abstract

Large language models can detect vulnerable code, yet the form of vulnerability encoding in their representations remains unclear. We analyze 8 code models spanning 6.7B-15B parameters on C programs using three datasets (DELTASECOMMITS, SVEN, and PRECISE-BUGS), comparing two diagnostic tasks on the same representations: identifying what patterns the code instantiates, and determining whether it is vulnerable. Models encode the first with high fidelity. Under the studied paired C-code datasets and linear-probing setup, vulnerability information is more accessible as a paired relational signal-whether code A is riskier than code B-than as a globally separable categorical label. This structural difference has implications for classification: the model reliably ranks which code is riskier but standard classifiers on isolated samples achieve limited accuracy because vulnerable and secure samples form overlapping distributions in representation space.

Figures & tables

Explore similar work

CardsList
  1. Dissecting the Black Box: Circuit-Level Analysis of LLM Vulnerability Detection

    May 28, 2026Syafiq Al Atiiq, Chun Zhou, Christian GehrmannLLM InterpretabilitySoftware Vulnerability Detection

  2. Words Speak Louder Than Code: Investigating Cognitive Heuristics in LLM-Based Code Vulnerability Detection

    Jun 29, 2026Asif Shahriar, Hongyu Cai, Hadjer Benkraouda +2Software Vulnerability DetectionAdversarial Attacks on LLMs