TL;DR
VeriCWEty is a novel framework that leverages LLM-derived vector embeddings to detect and localize hardware vulnerabilities (CWEs) in Verilog code. By combining module-level context with line-level analysis, it achieves 89% precision in identifying specific vulnerability types and 96% accuracy in pinpointing the exact lines where bugs occur.
What Problem Does This Paper Address?
As hardware design increasingly adopts Large Language Models (LLMs) for code generation, a critical security gap has emerged: the generated Register Transfer Level (RTL) code often contains subtle vulnerabilities known as Common Weakness Enumerations (CWEs).
Traditional detection methods struggle for several reasons. Static analysis tools (linters) rely on rigid, handcrafted rules that fail to capture the semantic complexity of hardware bugs. Formal verification is powerful but often too computationally expensive for large designs. Furthermore, existing automated approaches often treat CWEs as a flat list, ignoring the hierarchical and overlapping nature of hardware weaknesses. For instance, a bug involving "Shared Resource Leakage" (CWE-1245) is semantically distinct from "Internal Asset Exposure" (CWE-1244), yet they may manifest through similar syntactic patterns. There is a pressing need for a tool that can not only identify if a module is buggy but also what the bug is and where it resides.
Methods
The authors propose VeriCWEty, a three-stage pipeline that shifts from pattern-matching to semantic reasoning using vector embeddings.
-
Data Generation & Voting: To create a high-quality labeled dataset, the authors employ a "voting scheme." They query multiple state-of-the-art LLMs (including LLaMA 3.3, GPT-4o-mini, and Gemini 3) to identify CWE types and buggy lines in existing datasets. A majority-rule approach ensures the ground truth labels are robust.

- Embedding Generation: The framework uses a specialized model,
cl-verilog-1.0(a Code LLaMA variant fine-tuned on Verilog), to extract vector embeddings. These embeddings act as high-dimensional numerical signatures that capture the syntactic and semantic nuances of the code. - Classification & Localization: An XGBoost classifier is trained on these embeddings.
- Module-level: The model classifies the overall CWE type based on the module's embedding.
-
Line-level: To pinpoint bugs, the framework appends the overall module embedding to each individual line's embedding. This provides the classifier with the necessary micro-architectural context to decide if a specific line is part of a vulnerability.

Datasets
- BugWhisperer: The primary source, containing approximately 4,000 buggy RTL designs.
- Verigen: Used to provide 1,000 bug-free data points to serve as a negative control.
- Final Scope: The processed dataset for line-level detection totaled 3,000 unique modules and roughly 148,500 lines of code (LOC).
Key Insights and Ideas
- Semantics Over Syntax: By using embeddings rather than Abstract Syntax Trees (ASTs) or regex patterns, VeriCWEty can distinguish between closely related CWEs that look similar structurally but differ in their security implications.
- Context is King: A single line of Verilog might be perfectly safe in one module but catastrophic in another. The authors found that appending the module-level embedding to line-level embeddings significantly improved the model's ability to reduce False Positives (FPs).
- The "Weak Model" Trap: Initial experiments using weaker LLMs for labeling resulted in poor accuracy (0.591). The authors discovered that high-quality training data requires "strong" models (like GPT-5 variants or Gemini 3) that have a better grasp of hardware-specific security contexts.
- Handling Imbalance: Buggy lines are rare, accounting for only 4.2% of the total lines of code. The choice of XGBoost, configured specifically to handle class imbalance, was critical for achieving high recall.
Key Results
VeriCWEty demonstrates a significant step forward in automated hardware security analysis:
- High Precision: It identifies critical hardware vulnerabilities like CWE-1244 and CWE-1245 with 89% precision.
- Precise Localization: The framework achieves 96% accuracy in pinpointing the exact lines containing bugs.
- Superior Performance: In head-to-head comparisons for specific categories like improper access control, VeriCWEty achieved an f1-score of 0.87, outperforming the previous state-of-the-art tool, VerilogLAVD (0.70).
Limitations and Future Work
- Labeling Bottleneck: The system's performance is ultimately capped by the quality of the LLMs used for initial labeling. If the "voting" models share a common blind spot, the classifier will inherit it.
- CWE Diversity: While the framework handles 11 distinct CWEs, the full taxonomy of hardware weaknesses is much larger. Expanding the dataset to cover rarer or more complex multi-module vulnerabilities is a logical next step.
- Real-world Validation: While tested on open-source datasets, further evaluation on complex, industrial-scale SoCs (Systems-on-Chip) would further prove its utility in commercial design flows.
Summary updated