Game Rewards Vulnerabilities: Software Vulnerability Detection with Zero-Sum Game and Prototype Learning

Xin-Cheng Wen, Cuiyun Gao, Xinchen Wang, Ruiqi Wang, Tao Zhang, Qing LiaoarXiv 2024

Abstract

Recent years have witnessed a growing focus on automated software vulnerability detection. Notably, deep learning (DL)-based methods have demonstrated superior performance compared to other approaches. However, DL-based approaches still struggle to capture vulnerability-related information from whole code snippets, as vulnerable parts often account for only a small proportion. Our experiments show these approaches tend to over-emphasize semantic information, leading to limited performance in practical scenarios. Specifically, they fail to distinguish between vulnerable and fixed code due to minimal changes and suffer significant performance degradation (up to 14.53% F1 score) when identifiers are substituted. To mitigate these issues, we propose RECON, a framework utilizing a zero-sum game and prototype learning. RECON captures semantic-agnostic features by pitting a "Calibrator" (distinguishing vulnerable from fixed code) against a "Detector" (standard detection). Experiments show RECON outperforms state-of-the-art baselines by 6.29% in F1 score.

The Challenge of Vulnerability Detection

Deep learning (DL) has become a primary tool for identifying security vulnerabilities in source code. However, these models often rely on "semantic shortcuts"—learning that specific variable names or function labels correlate with vulnerabilities rather than understanding the underlying logic.

The authors identify two critical hurdles:

  1. The "Minimal Change" Blind Spot: Code fixes are often subtle, such as a single type cast or an added check. Standard models struggle to differentiate between the "before" (vulnerable) and "after" (fixed) versions because of their high textual similarity.
  2. Identifier Sensitivity: Models are overly dependent on developer-chosen names. Replacing user-defined identifiers with generic placeholders (e.g., "VAR1") causes performance to drop by as much as 14.53% in F1 score for top-tier models.
Minimal code changes and performance degradation under identifier substitution.

The RECON Framework

To address these limitations, we introduced RECON (REvulnerability dEteCtion framework with zerO-sum game and prototype learNing). The framework employs two primary strategies to force the model to learn structural, semantic-agnostic features.

Zero-Sum Game Construction

RECON establishes a competition between two neural network modules:

  • The Detector: A standard player aiming to classify code as vulnerable or non-vulnerable.
  • The Calibrator: A specialized player tasked with the harder job of distinguishing a vulnerable snippet from its nearly identical developer-fixed counterpart.

By sharing a feature extractor, the Calibrator forces the system to identify structural "tells" that persist even when variable names change.

Class-Level Prototype Learning

To maintain stability during competitive training, RECON learns "prototypes"—representative mathematical vectors for vulnerable and clean code. The model pulls code snippets toward their respective prototypes, ensuring a robust representation of each class.

The RECON framework: (A) Zero-sum Game between Detector and Calibrator, and (B) Class-Level Prototype Learning.

Experimental Evaluation

RECON was evaluated using the Fan et al. (2020) dataset, comprising 188,000 code samples across 348 GitHub projects. This dataset is unique in providing vulnerability-fix pairs, essential for training the Calibrator.

Key Results

  • Superior Performance: RECON outperformed the best baseline (EPVD) by 6.29% in F1 score and 0.94% in accuracy in the original setting.
  • Robustness to Obfuscation: In identifier substitution tests, RECON maintained higher performance, improving F1 scores by 5.75% over the best baseline.
  • Precision in Fix Identification: RECON was 3.63% more accurate at distinguishing between vulnerable code and its fix compared to other models.

Conclusion

RECON demonstrates that treating vulnerability detection as a competitive game forces AI to move beyond superficial semantic cues toward a deeper understanding of code structure. While currently focused on C/C++, the principles of zero-sum calibration and prototype learning offer a promising path for robust, language-agnostic vulnerability detection in the future.

Summary updated

BibTeX
@misc{wen2024game,
  author = {Xin-Cheng Wen and Cuiyun Gao and Xinchen Wang and Ruiqi Wang and Tao Zhang and Qing Liao},
  title = {{Game Rewards Vulnerabilities: Software Vulnerability Detection with Zero-Sum Game and Prototype Learning}},
  year = {2024},
  eprint = {2401.08131},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.08131},
}
Figure