Open Access iconOpen Access

ARTICLE

crossmark

Syntax-Aware Hierarchical Attention Networks for Code Vulnerability Detection

Yongbo Jiang, Shengnan Huang, Tao Feng, Baofeng Duan*

School of Computer and Communication, Lanzhou University of Technology, Lanzhou, 730050, China

* Corresponding Author: Baofeng Duan. Email: email

Computers, Materials & Continua 2026, 86(1), 1-22. https://doi.org/10.32604/cmc.2025.069423

Abstract

In the context of modern software development characterized by increasing complexity and compressed development cycles, traditional static vulnerability detection methods face prominent challenges including high false positive rates and missed detections of complex logic due to their over-reliance on rule templates. This paper proposes a Syntax-Aware Hierarchical Attention Network (SAHAN) model, which achieves high-precision vulnerability detection through grammar-rule-driven multi-granularity code slicing and hierarchical semantic fusion mechanisms. The SAHAN model first generates Syntax Independent Units (SIUs), which slices the code based on Abstract Syntax Tree (AST) and predefined grammar rules, retaining vulnerability-sensitive contexts. Following this, through a hierarchical attention mechanism, the local syntax-aware layer encodes fine-grained patterns within SIUs, while the global semantic correlation layer captures vulnerability chains across SIUs, achieving synergistic modeling of syntax and semantics. Experiments show that on benchmark datasets like QEMU, SAHAN significantly improves detection performance by 4.8% to 13.1% on average compared to baseline models such as Devign and VulDeePecker.

Keywords

Vulnerability detection; abstract syntax tree; syntax rule slicing; hierarchical attention mechanism; deep learning

Cite This Article

APA Style
Jiang, Y., Huang, S., Feng, T., Duan, B. (2026). Syntax-Aware Hierarchical Attention Networks for Code Vulnerability Detection. Computers, Materials & Continua, 86(1), 1–22. https://doi.org/10.32604/cmc.2025.069423
Vancouver Style
Jiang Y, Huang S, Feng T, Duan B. Syntax-Aware Hierarchical Attention Networks for Code Vulnerability Detection. Comput Mater Contin. 2026;86(1):1–22. https://doi.org/10.32604/cmc.2025.069423
IEEE Style
Y. Jiang, S. Huang, T. Feng, and B. Duan, “Syntax-Aware Hierarchical Attention Networks for Code Vulnerability Detection,” Comput. Mater. Contin., vol. 86, no. 1, pp. 1–22, 2026. https://doi.org/10.32604/cmc.2025.069423



cc Copyright © 2026 The Author(s). Published by Tech Science Press.
This work is licensed under a Creative Commons Attribution 4.0 International License , which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
  • 269

    View

  • 90

    Download

  • 0

    Like

Share Link