Cross Domain Vulnerability Detection using Graph Contrastive Learning

Mahmoud Zamani, Saquib Irtiza, Shamila Wickramasuriya, Latifur Khan, Kevin HamlenOpenReview 2023 · Submission to Tiny Papers @ ICLR

TL;DR

This paper introduces a novel graph representation called Cross-Domain Control Property Graph (CDCPG) that combines source code and binary code features to detect software vulnerabilities. By training a self-supervised contrastive learning model (GraphCL) on this new graph type, the authors demonstrate a significant improvement in vulnerability detection accuracy compared to methods relying on source code or binary code alone.

What Problem Does This Paper Address?

Manually auditing large software systems for vulnerabilities is incredibly challenging and time-consuming. While automated methods exist, they often struggle with the sheer complexity of modern software and the difficulty of obtaining large, high-quality labeled datasets for training machine learning models. Existing graph-based approaches for vulnerability detection, like those using Abstract Syntax Trees (ASTs), Control Flow Graphs (CFGs), and Code Property Graphs (CPGs), primarily focus on source code. This leaves a critical blind spot: vulnerabilities introduced or altered during the compilation process (binary-level vulnerabilities) that are invisible at the source code level. This paper aims to bridge this gap by developing a method that can detect vulnerabilities present in both source code and its compiled binary form.

Methods

The core innovation of this paper lies in the creation of the Cross-Domain Control Property Graph (CDCPG). This new graph representation integrates features from both source-level Code Property Graphs (CPGs) and binary-level code analysis. Specifically, they use tools like Joern to generate AST, CFG, and CPGs from source code, and the Binary Analysis Platform (BAP) to generate "BIN" graphs from compiled binaries. The CDCPG then combines these, introducing new edge types to represent the relationships between source and binary components.

To train a model on these graphs without relying on extensive labeled data, the authors employ Graph Contrastive Learning (GraphCL). This self-supervised learning technique learns to distinguish between different augmented views of the same graph (positive pairs) and views of different graphs (negative pairs). They experiment with various graph augmentation techniques (e.g., edge addition/removal, node dropping, feature masking) and loss functions (InfoNCE, JSD) to find the optimal configuration for their CDCPG representation.

Datasets

The authors introduce a new curated dataset for vulnerability detection. This dataset is built from the code repositories of six widely used open-source C/C++ applications, including Sudo, LibPNG, LibTIFF, TCPDump, TinTin, and OpenSSH. For each application, they generate multiple graph types: AST, CFG, CPG, BIN, and their proposed CDCPG. The dataset includes information on vulnerable and non-vulnerable functions within these applications.

Key Insights and Ideas

  • Bridging the Source-Binary Divide: The most significant insight is that combining source code and binary code features into a single graph representation (CDCPG) is crucial for comprehensive vulnerability detection. Vulnerabilities can exist at either level, and a unified view is necessary to catch them all.
  • Self-Supervised Learning is Key: The paper strongly advocates for self-supervised learning (SSL) methods like GraphCL in domains where labeled data is scarce and expensive to obtain. This approach allows for effective model training without the need for massive, manually annotated datasets.
  • Augmentation and Loss Function Synergy: The effectiveness of GraphCL is highly dependent on the choice of augmentation techniques and loss functions. The paper highlights that specific combinations can significantly impact performance, suggesting that careful tuning is essential.

Key Results

The paper demonstrates that their CDCPG representation, when used with GraphCL, outperforms other graph types (AST, CFG, CPG, BIN) in vulnerability detection. For instance, on the TCPDump application, CDCPG achieved perfect F1-Micro and F1-Macro scores (1.00), while other graph types scored significantly lower (e.g., AST: 0.85 F1-Micro, 0.46 F1-Macro; CPG/CFG/BIN: 0.63 F1-Micro, 0.39 F1-Macro). Across all six applications, CDCPG consistently showed superior performance. Further experiments indicated that the Node Dropping (ND) augmentation technique combined with the Jensen-Shannon Divergence (JSD) loss function yielded the best results for CDCPG.

Limitations and Future Work

The authors acknowledge that their work focuses on C/C++ applications. Future work could explore extending this approach to other programming languages. While they have curated a dataset from six applications, expanding this dataset to include a wider variety of software and vulnerability types would further strengthen the generalizability of their findings. The paper also suggests that further research into optimizing graph augmentation strategies and loss functions for contrastive learning in this domain could lead to even greater improvements.

Summary updated

BibTeX
@misc{zamani2023cross,
  author = {Mahmoud Zamani and Saquib Irtiza and Shamila Wickramasuriya and Latifur Khan and Kevin Hamlen},
  title = {{Cross Domain Vulnerability Detection using Graph Contrastive Learning}},
  year = {2023},
  url = {https://openreview.net/forum?id=rrZtzI7xj2b},
  howpublished = {OpenReview},
  note = {Submitted to Tiny Papers @ ICLR},
}
Figure