Organizations: NYU Tandon School of Engineering, New York, US · NYU Abu Dhabi, Abu Dhabi, UAE · NYU Abu Dhabi, Center for Cyber Security, Abu Dhabi, UAE
Large Language Models (LLMs) have shown significant improvement in RTL code generation. Despite the advances, the generated code is often riddled with common vulnerabilities and weaknesses (CWEs) that can slip by untrained eyes. Attackers can often exploit these weaknesses to fulfill their nefarious motives. Existing RTL bug-detection techniques rely on rule-based checks, formal properties, or coarse-grained structural analysis, which either fail to capture semantic vulnerabilities or lack precise localization. In our work, we bridge this gap by proposing an embedding-based bug-detection framework that detects and classifies bugs at both module and line-level granularity. Our method achieves about 89% precision in identifying common CWEs such as CWE-1244 and CWE-1245, and 96% accuracy in detecting line-level bugs.
Figures & tables
CWE
Description
CWE-250
Execution with unnecessary privileges, increasing attack impact.
Improper access control enabling unauthorized resource access.
CWE-310
Cryptographic issues due to weak or improper algorithms/usage.
CWE-321
Use of hard-coded cryptographic key in code.
CWE-506
Embedded malicious code (e.g., backdoor, trojan).
TABLE I: List of CWEs commonly used in the literature.
Fig. 1: Voting scheme determines the module-level CWEs and line-level bugs
Fig. 2: End-to-end VeriCWEty pipeline including data generation, embedding extraction, training, and inference
Class
Prec.
Rec.
F1
Sup.
CWE-1244
0.547
0.506
0.526
81
CWE-1245
0.431
0.383
0.405
81
CWE-1260
0.529
0.450
0.487
20
CWE-1271
0.000
0.000
0.000
3
CWE-284
0.915
0.667
0.771
81
CWE-310-AES-LEAK
0.822
0.914
0.866
81
TABLE II: Performance with initial annotation (baseline) using weak models
Model
Total Samples
Mismatches
Correct%
Deepseek-v3.2
50
34
32
LLaMA-3.3-70b-instruct
50
36
28
GPT-4o-mini
50
25
50
Gemini3
50
10
80
GPT-5-Nano
50
4
92
GPT-5.4
50
3
94
TABLE III: Number of mis-prediction of CWE by different models
CWE Type
# Train
Train (%)
# Test
Test (%)
CWE-1244
1106
38.05
276
37.96
CWE-1245
779
26.80
213
29.30
NONE
561
19.30
120
16.51
CWE-310-AES-LEAK
173
5.95
50
6.88
CWE-321
103
3.54
26
3.58
CWE-1271
55
1.89
16
2.20
TABLE IV: Distribution of CWE Types in Training and Test Datasets
Class
Prec.
Rec.
F1
Sup.
CWE-1244
0.886
0.870
0.878
276
CWE-1245
0.884
0.789
0.834
213
CWE-310-AES-DOS
0.556
0.556
0.556
9
CWE-310-AES-LEAK
0.576
0.680
0.624
50
CWE-310-CSR-UNAUTH
0.333
0.200
0.250
5
CWE-321
0.477
0.808
0.600
26
TABLE V: “Final performance after improved annotation and training using stronger latest models like GPT-5.4, GPT-5-Nano, and Gemini3 for labeling the dataset
Fig. 3: Line-level embeddings vs. Line-level + Module-level embeddings classification analysis. Starting from top left and going clock-wise (a) Metric Comparison (b) Precision-Recall Curve (c) Threshold Settings (d) Confusion Matrix for only Line-level embeddings for test (e) Confusion Matrix for Line-level combined with Module-level embeddings for test (f) FP/FN trade off
Large language models (LLMs) can detect software vulnerabilities, but how do they actually identify vulnerable code? We address this question using mechanistic interpretability; analyzing the internal computations of a neural network to understand its reasoning process.Using Circuit Tracer on Gemma-2-2b, we trace the computational pathways activated when the model classifies 472 C/C++ code samples as vulnerable or safe. Our analysis reveals a surprising finding: the model primarily relies on safety detectors, attention heads that recognize safe coding patterns, rather than directly detecting vulnerability signatures. When these safety detectors fail to activate, the model classifies code as vulnerable. We identify the critical neural components: specific attention heads in early layers (L5, L7) that focus on safety patterns, and Multilayer Perceptron (MLP) neurons in Layer 7 that encode vulnerability-related features. Ablation experiments confirm their causal role; removing Layer 11 drops vulnerability detection accuracy from 100% to 6%, while ablating just 20 neurons in Layer 7 reduces it by 50%.Our findings show that LLM vulnerability detection uses sparse, interpretable circuits (only 16% of model capacity), enabling circuit-level explanations for security predictions and targeted improvements to detection systems.
The rapid adoption of LLM-powered code generation has dramatically accelerated software development, yet effective verification methods remain severely underdeveloped. Existing bug localization techniques are either prohibitively expensive, requiring minutes of agentic reasoning and thousands of generated tokens per file, and/or operate at coarse function-level granularity unsuitable for precise debugging. While works that focus on line-level granularity and are more light-weight are often limited in their performance or context size. We introduce a novel line-level bug localization approach that addresses these limitations through three key contributions: (1) a token alignment algorithm that overcomes fundamental tokenization challenges in previous work, (2) a lightweight multi-task LLM for bug localization (MLC) enabling efficient line-level bug classification, and (3) an optimized training recipe for multi-line prediction. Our method achieves state-of-the-art performance among similar setups on line-level bug localization with full-file context. At the same time we reach comparable performance to agentic approaches on Defects4J and PypiBugs benchmarks while reducing inference latency by orders of magnitudes, requiring only a single generated token per file. We further demonstrate strong generalization by introducing and evaluating on a small out-of-domain evaluation datasets in Python. We will open source our code, models, and datasets upon acceptance.
Nikolai Rozanov
Department of Computing, Imperial College London, London, UK
Verilog debugging remains one of the most time-consuming stages in digital circuit design. Recent advances in Large Language Models (LLMs) have enabled automated debugging; however, most existing approaches rely solely on test outputs and compiler feedback in an end-to-end manner, limiting their effectiveness on complex bugs. A key challenge is that the root cause of an error may be far removed from its observable outputs, making it difficult for LLMs to trace long dependency chains in code. This challenge is further exacerbated in large codebases, where long context lengths hinder efficient reasoning. To address these limitations, we propose VeriPilot, an LLM-powered debugging framework that leverages golden reference models to enable fine-grained bug localization and repair. VeriPilot goes beyond output-level comparison by aligning internal variable semantics between the Verilog design and its corresponding golden model through LLM-based analysis. It then performs step-by-step signal tracing using Control-Data-Flow Graphs (CDFGs) derived from static analysis, identifying a minimal set of suspicious code regions along with their correct counterparts from the golden model. These structured insights are subsequently provided to the LLM to guide reasoning and automated code repair. Experimental results on the Comprehensive Verilog Design Problems (CVDP) benchmark from NVIDIA demonstrate that VeriPilot improves the repair success rate of GPT-4o from 54.3% to 85.71%, significantly enhancing both bug localization accuracy and repair effectiveness for complex Verilog designs. The source code and benchmark are publicly available at Github https://github.com/YihanWn/VeriPilot.git.
Yihan Wang, Cheng Liu, Jiazheng Zhang +4
State Key Lab of Processors, Institute of Computing Technology, Chinese Academy of Sciences, and the University of Chinese Academy of Sciences, Beijing, China · North China Electric Power University, Beijing 102206, China