系统工程与电子技术 ›› 2023, Vol. 45 ›› Issue (5): 1535-1543.doi: 10.12305/j.issn.1001-506X.2023.05.31

• 通信与网络 • 上一篇    

基于图表示和MHGAT的代码漏洞静态检测方法

程靖云, 王布宏, 罗鹏   

  1. 空军工程大学信息与导航学院, 陕西 西安 710077
  • 收稿日期:2022-03-16 出版日期:2023-04-21 发布日期:2023-04-28
  • 通讯作者: 程靖云
  • 作者简介:程靖云(1998—), 男, 硕士研究生, 主要研究方向为信息安全
    王布宏(1975—), 男, 教授, 博士, 主要研究方向为信息安全、物理层安全、人工智能安全
    罗鹏(1995—), 男, 博士研究生, 主要研究方向为信息安全

Code vulnerability static detection method based on graphrepresentation and MHGAT

Jingyun CHENG, Buhong WANG, Peng LUO   

  1. College of Information and Navigation, Air Force Engineering University, Xi'an 710077, China
  • Received:2022-03-16 Online:2023-04-21 Published:2023-04-28
  • Contact: Jingyun CHENG

摘要:

针对现有的静态分析技术难以及时、准确地检测软件安全漏洞的问题, 提出了一种基于图表示和多头图注意力网络(multi-head graph attention network, MHGAT)的代码漏洞静态检测方法。首先, 通过程序切片从源代码的系统依赖图中提取漏洞代码片段, 根据系统依赖图构建不同语句间连接关系的邻接矩阵, 并采用嵌入算法获取代码片段的特征矩阵; 然后, 将多个代码片段的邻接矩阵和特征矩阵以不相交图的形式进行拼接; 最后, 使用多个卷积-池化基本块获取代码图数据在不同层次上的特征, 并利用跳跃知识网络集成各个基本块的输出。实验结果表明, 相比其他漏洞检测方法, 所提方法通过数据表征形式和算法上的改进, 有效提高了漏洞检测的效率和效果。

关键词: 漏洞检测, 程序切片, 图表征学习, 图注意力网络, 多头自注意力

Abstract:

Aiming at the problem that the existing static analysis technology is difficult to detect software security vulnerabilities timely and accurately, a code vulnerability static detection method based on graph representation and multi-head graph attention network (MHGAT) is proposed. Firstly, vulnerability code snippets are extracted from the system dependency graph of source code by program slicing, adjacency matrix of connection relation between different statements is constructed according to the system dependency graph, and feature matrix of code snippet is obtained by embedding algorithm. Then, the adjacency matrix and feature matrix of multiple code snippets are spliced in the form of disjoint graph. Finally, multiple convolution-pooling basic blocks are used to obtain the characteristics of code graph data at different levels, and the output of each basic block is integrated by jumping knowledge network. Experimental results show that compared with other vulnerability detection methods, the proposed method can effectively improve the efficiency and effectiveness of vulnerability detection through the improvement of data representation form and algorithm.

Key words: vulnerability detection, program slicing, graph representation learning, graph attention network, multi-head self-attention

中图分类号: