arXiv(opens in a new tab)cs.CROct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.06366

Correct Verdicts, Flawed Reasoning: Structured Auditing of LLM-based Vulnerability Reasoning

Boyue Caroline Hu, Kaivalya Ahir, Ronghao Ni, Limin Jia

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

BOYUE CAROLINE HU, Carnegie Mellon University, USA

KAIVALYA AHIR, Carnegie Mellon University, USA

RONGHAO NI, Carnegie Mellon University, USA

LIMIN JIA, Carnegie Mellon University, USA

Large Language Models (LLMs) are increasingly deployed for automated software vulnerability analysis. Binary classification alone is often insufficient; practitioners need explanations to triage reported bugs and engineer patches. Standard practice relies on Chain-of-Thought (CoT) prompting to elicit such explanations. However, because CoT represents reasoning as free-form natural language, models can obscure logical leaps, hallucinated execution steps, and internal inconsistencies behind plausible prose, leading to correct verdict, flawed reasoning, such as reaching the correct verdict via a non-existent execution path. Our manual audit reveals that approximately 60% of correct vulnerability verdicts are accompanied by these fabricated or unverifiable claims. Free-form explanations allow reasoning errors to evade LLM-as-a-judge evaluation.

To better audit LLM reasoning, we present Vulnerability Explanation Reasoning Auditor (VERA), an automated framework for auditing whether the explanation adheres to the source code; and whether it contains logical contradiction. Rather than accepting free-form text, VERA first asks models to output a Structured Reasoning Record (SRR), encoding the information necessary for vulnerability reasoning into machine-readable fields, including tracked pointers, memory operations, and state transitions. A multi-stage judge then audits each SRR against eight well-defined reasoning failure modes. Most stages use deterministic syntactic checks, with LLM calls reserved only when semantic interpretation is required. Furthermore, the standardized schema of SRRs enables automated mutation testing to benchmark reasoning judges at scale without human annotation. Our empirical evaluation demonstrates that reasoning flaws occur in correct verdicts just as frequently as in incorrect ones, and VERA exposes 87% of reasoning errors that free-form LLM-as-judge systematically miss. VERA replaces blind trust in CoT prose with structured reasoning audits, filtering hallucinated vulnerability reports and pinpointing stage-specific failures.

CCS Concepts: • Software and its engineering → Software testing and debugging; Software maintenance tools; • Computing methodologies → Machine learning; • Security and privacy → Software and application security.

Additional Key Words and Phrases: vulnerability detection, LLM reasoning auditing, LLM-as-judge

ACM Reference Format:

Boyue Caroline Hu, Kaivalya Ahir, Ronghao Ni, and Limin Jia. 2027. Correct Verdicts, Flawed Reasoning: Structured Auditing of LLM-based Vulnerability Reasoning. 1, 1 (October 2027), 23 pages. https://doi.org/XXXXXXX.XXXXXXX

Authors' Contact Information: Boyue Caroline Hu, boyuecah@andrew.cmu.edu, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA; Kaivalya Ahir, kahir@andrew.cmu.edu, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA; Ronghao Ni, ronghaon@andrew.cmu.edu, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA; Limin Jia, liminjia@andrew.cmu.edu, Carnegie Mellon University, Pittsburgh, Pennsylvania, USA.

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.

© 2027 Copyright held by the owner/author(s). Publication rights licensed to ACM.

ACM XXXX-XXXX/2027/10-ART

https://doi.org/XXXXXXX.XXXXXXX

Boyue Caroline Hu, Kaivalya Ahir, Ronghao Ni, and Limin Jia

Figure

(a) Chain-of-Thought (CoT) detection and LLM-as-judge baseline. Example on the right shows the LLM fabricates a cause via a stale comment; free-form prose makes the error invisible to the LLM-as-judge.

I. LLM vulnerability reasoning

Figure

(b) Overview of VERA. VERA asks the detection LLM to structure its reasoning into an SRR, then audits it with a multi-stage judge, producing per-stage auditing results.

evict_entry(cache_t *cache, int key) >= variable state

1 typedef struct { 2 char *name; int refs; 3 } entry_t; 4 5 void cache_remove(cache_t *cache, int key) {/removes key from index only/ 6 ... } %Note: not freeing e% 7 8 void evict_entry(cache_t *cache, int key) { 9 entry_t e = cache_lookup(cache, key); 10 if (!e) return; 11 cache_remove(cache, key); / removes entry e %Note: stale comment% */ 12 if (-e->refs == 0) { 13 free(e->name); @e->name: Freed 14 free(e); @e: Freed 15 } 16 audit_log("evicted %d: %s", key, e->name); @UAF: e->name is Freed 17 }

(c) When e->refs reaches zero, Ⓐ e->name and Ⓑ e are freed. Then audit_log dereferences e->name in the Freed state, causing the UAF.

(d) State-based specification of CWE-416 Use-After-Free (UAF): accessing pointers in the Freed state.

Figure

Figure

(e) Example of reasoning auditing with VERA. Structuring reasoning into an auditable SRR enables judges to detect missed memory operations and false assumptions.

Fig. 1. Overview of VERA with a motivating example of correct verdict, flawed reasoning.

1 Introduction

Large Language Models (LLMs) are increasingly being adopted for automated vulnerability detection in software security [14, 21, 44, 50, 64]. Trust in LLM-generated vulnerability assessments depends not only on the final verdict but also on the underlying reasoning, especially in security-critical settings [30, 37]. Explanations of where and why a vulnerability exists help developers and security analysts validate findings and make informed patching and auditing decisions. However, LLMs may provide hallucinated explanations and justifications [29]. A common LLM-based vulnerability analysis approach is to use unconstrained Chain-of-Thought (CoT) reasoning in natural language. While flexible, free-form CoT allows models to produce plausible-sounding but fundamentally hallucinated justifications [24, 32, 38, 47, 57], a phenomenon we refer to as “correct verdicts, flawed reasoning.”

For example, the program in Fig. 1c has a Use-After-Free (UAF) vulnerability (CWE-416 [41]). A common way to explain the vulnerability is that when the reference count is zero (L12), the pointers e->name and e are freed on lines L13, 14, then the dereferencing e->name in audit_log (L16) leads to UAF. When prompted to identify and explain the vulnerability in this program, as illustrated in Fig. 1a, LLM via CoT correctly identified UAF, but its reasoning falsely assumes cache_remove frees e (L11) then dereferencing e->refs (L12) is the UAF. This error violates basic code adherence as the reasoning was based on the stale comment (L11) rather than actual implementation. Though not shown in the example, reasoning could also contain logical contradictions, such as explicitly identifying a vulnerability step-by-step only to conclude with a “Safe” final verdict.

Our manual review of free-form CoT reasoning generated by four state-of-the-art LLMs revealed that LLMs frequently provide explanations with hallucinated external knowledge (55-61% factually incorrect) or unverifiable code assumptions (19-34%) (more details in Sec. 2). Relying on flawed explanations in production carries significant risk: engineers acting on hallucinated logic may write broken patches, while high benchmark accuracy conceals critical model failure modes (e.g., missing the actual UAF in Fig. 1c). Addressing this requires a framework that checks whether underlying reasoning by the LLMs is both grounded in facts about the source code and are logically consistent.

The primary challenge of auditing LLM vulnerability reasoning is that free-form CoT reasoning lacks explicit structure and intermediate checkable steps, e.g., where pointers are freed and dereferenced. Furthermore, unlike algorithmic or boolean problems where intermediate logical steps unfold sequentially, checkable reasoning steps for vulnerability analysis need to be explicitly formalized and structured. Hence, recent efforts have turned to LLM-as-judge approaches [26, 37, 71] (Step II of Fig. 1a); however, evaluating unstructured natural language with another neural model is still prone to hallucinations and yields no verifiable evidences. For instance, in Fig. 1a, the LLM-as-judge is likewise misled by the stale comment and misses the error. Human experts can detect such issues, but their review does not scale.

Our core insight is that for vulnerability analysis, checkable intermediate reasoning steps naturally correspond to program state transitions and that a broad spectrum of vulnerability classes, from memory safety to resource lifecycle errors, can be specified as state sequences. For instance, finding a UAF can be described as a process of finding operations that transition a pointer to Allocated state and then to Freed, and look for a dereference operation of any Freed pointer. In Fig. 1c, this sequence is e->refs==0 (L12), then e->name and e are freed (L13, 14), and the dereferencing e->name in audit_log (L16) leads to UAF (Fig. 1d). By instructing the LLM to explicitly track and output these state changes, we transform natural language reasoning into a machine-readable schema that can be deterministically checked against the input source code.

Building on this insight, we present VERA (Vulnerability Explanation Reasoning Auditor), a framework that constrains LLM explanations to structured, auditable reasoning traces and performs automatic audit. Fig. 1b illustrates the architecture of VERA. We focus on vulnerability reasoning by LLMs when given a slice of the project (e.g., key function definitions). This is widely favored in practice because it is computationally efficient, scales across massive codebases, and operates directly on source code without requiring a fully compilable build environment. Rather than relying on high-level CWE categories paired with free-form CoT prompts, we first specify vulnerabilities as sequences of state transitions. VERA then instructs the LLM to output a Structured Reasoning Record (SRR) that explicitly materializes checkable intermediate reasoning steps, including variable states, state-changing operations, and operational assumptions, into an inspectable format for auditing (Step I in Fig. 1b). In the example in Fig. 1e, the SRR explicitly records the intermediate assumption about cache_remove that it frees e, then the conclusion that e->refs is the site of the UAF that can later be detected during auditing.

Next, VERA performs reasoning auditing by evaluating the SRR through a multi-stage judge to detect reasoning breakdowns across a comprehensive taxonomy of fundamental failure modes (Step II). We define reasoning auditing as evaluating code adherence and internal consistency. The

Boyue Caroline Hu, Kaivalya Ahir, Ronghao Ni, and Limin Jia

former refers to checking whether each claim in an LLM’s reasoning chain is syntactically and semantically supported by the provided source code slice [26] (e.g., whether variables named in the trace are actually declared). The later refers to verifying that intermediate trace steps remain logically coherent and strictly support the final verdict (e.g., ensuring the final vulnerable verdict does not contradict the trace). Note that neither check requires ground-truth reasoning annotations which do not exist in real-world applications. Existing vulnerability validation techniques are fundamentally unsuited for this task. Benchmark studies evaluate only final detection metrics, treating internal reasoning as a black box [9, 14, 20]. Traditional static tools [5, 49, 65] focus on rule-based detection rather than explanatory auditability, frequently flooding triage queues with high false-positive rates without explaining root causes. Dynamic validation methods (e.g., fuzzing [23, 48, 63] or sanitizer-based execution [43, 52]) and LLM-based vulnerability validation [26, 37, 71] have a fundamentally different goal from reasoning auditing. They confirm whether the detected bug exists or executes at runtime rather than whether the explanatory reasoning is sound. To remain broadly applicable across diverse programming languages and vulnerability classes (CWEs) without requiring language-specific static analyzers or heavy compilation toolchains, VERA’s judge relies primarily on deterministic AST parsing for syntactic checking, reserving targeted LLM calls strictly for higher-level semantic checks. By evaluating the SRR rather than unstructured text, VERA exposes both reasoning mistakes in the example: the omitted memory operations and the invalid assumption drawn from the stale comment.

In summary, this paper makes the following contributions. 1) VERA: A Reasoning Audit Framework for Vulnerability Analysis. VERA takes an initial step toward systematic LLM reasoning validation in software security by providing an automated framework to audit code adherence and internal consistency in vulnerability reasoning. 2) Automated Mutation Testing for Reasoning Judges. Evaluating reasoning evaluators has traditionally required unscalable human inspection. By formalizing reasoning into explicit, machine-readable SRRs, VERA enables automated, ground-truth-free mutation testing of reasoning judges, providing a scalable framework to automatically benchmark judge precision and recall without human spot-checks. 3) Empirical Findings & Practical Impact: Our experiments using VERA reveal three critical insights. First, reasoning flaws occur in correct verdicts just as frequently as incorrect ones, models are right for the wrong reasons as often as they are simply wrong, making reasoning audit necessary. Second, false positives are systematic and structure-driven: models repeat identical reasoning mistakes on safe functions and their patched variants. Third, VERA's per-stage decomposition reveals code-structural patterns that drive specific reasoning failures. By surfacing failures as explicit stage-level findings, VERA reduces manual effort to audit LLM reasoning chains for security analysts and provides LLM developers with actionable diagnostics for targeted fine-tuning and benchmark design.

The rest of this paper is organized as follows. Sec. 2 motives VERA by demonstrating empirically that CoT reasoning is unreliable and unauditable. Sec. 3 introduces our state-based vulnerability specifications, reasoning failure taxonomy, and the Structured Reasoning Record (SRR) schema of VERA. Sec. 4 presents the multi-stage judge and mutation testing for judges. Sec. 5 reports evaluation results. Finally, we review related work in Sec. 6 and conclude in Sec. 7.

References (28)