Vulnerability Prediction Based on Weighted Software Network for Secure Software Building

Shengjun Wei, Hao Zhong, Chun Shan, Lin Ye, Xiaojiang Du, Mohsen Guizani

TL;DR

This paper introduces a novel Vulnerability Prediction Model (VPM) that treats software architectures as weighted, directed networks rather than simple binary graphs. By quantifying the intensity of dependencies between C++ classes, the model achieves significant performance gains, improving average prediction precision by 27.7% and recall by 42.7% compared to traditional unweighted approaches.

What Problem Does This Paper Address?

As software systems grow exponentially in complexity, finding security vulnerabilities before deployment becomes a massive bottleneck. Developers face tight budgets and strict deadlines, making it impossible to test every line of code exhaustively. Vulnerability Prediction Models (VPMs) help prioritize limited testing resources by flagging the most "vulnerability-prone" modules ahead of time.

While previous research used software network analysis (graphing code units as nodes and dependencies as edges) to predict defects, these models typically treated dependencies as binary: an edge either existed (1) or it didn't (0). In reality, the degree of dependence between two classes varies wildly. A class that relies heavily on another for dozens of functions is riskier than one with a single, minor interaction. This paper addresses this gap by introducing a weighted, directed software network to capture the true intensity of code dependencies.

Methods

The authors construct a Weighted Software Network (WSN) at the class granularity level.

  1. Graph Construction: Nodes represent C++ classes, and directed edges represent dependencies like inheritance or association.
  2. Edge Weighting: The weight of an edge between Class A and Class B is calculated based on the proportion of interacting functions between them. If Class A relies on many functions in Class B, the edge weight approaches 1; if it's a minor interaction, it approaches 0.
  3. Feature Extraction: For each node (class), the authors extract seven distinct metrics:
  4. Traditional Complexity Metrics: Lines of code, number of functions, and average Cyclomatic Complexity.
  5. Network Topology Metrics: Intensity of input (weighted in-degree), intensity of output (weighted out-degree), clustering coefficient, and betweenness centrality.
  6. Classification: The authors feed these metrics into five standard machine learning algorithms via the Weka toolset: Bayesian Networks (BN), Naïve Bayes (NB), Neural Networks (NN), Random Forests (RF), and Support Vector Machines (SVM).
  7. Class Imbalance Handling: Because vulnerable classes are rare (less than 10% of the codebase), the authors use random under-sampling to create a balanced 1:1 dataset for training and 10-fold cross-validation.

Datasets

The model was evaluated using Mozilla Firefox (from its first release up to Firefox 43).

To gather the ground-truth data, the authors built a custom web crawler that traced a pipeline from public security advisories to actual source code: $$\text{Mozilla Foundation Security Advisories (MFSA)} \rightarrow \text{Bugzilla Bug IDs} \rightarrow \text{Patched Files} \rightarrow \text{Vulnerable C++ Classes}$$

The resulting dataset mapped out 6,835 C++ classes, of which 616 were identified as historically vulnerable.

Key Insights and Ideas

  • Binary Edges Hide Risk: An unweighted graph treats a class with three function dependencies the same as a class with one. By weighting the edges, the authors prove that higher dependency intensity directly correlates with a class's vulnerability-proneness and its ability to propagate defects.
  • The Power of Topology: Traditional code metrics (like lines of code) only tell you about a class in isolation. Network metrics like betweenness centrality reveal how critical a class is to the rest of the system's data flow, capturing architectural risk that simple code scanners miss.
  • Neural Networks Reign Supreme: When paired with network topology features, Neural Networks (NN) outperformed the other four machine learning models, proving highly adept at navigating the non-linear relationships between network centrality and security risk.

Key Results

The weighted network approach yielded strong predictive performance across all tested machine learning models:

  • Top Performer: The Neural Network (NN) achieved an Accuracy of 90.50%, a Precision of 90.83%, and a Recall of 90.18%, while keeping the False Positive rate down to 9.18%.
  • Average Performance: Across all five algorithms, the average accuracy was 86.02%, precision was 86.85%, and recall was 84.96%.
  • Comparison to Unweighted Baselines: Compared to prior state-of-the-art models using unweighted component dependency graphs (e.g., Nguyen et al.), this method demonstrated a massive leap in performance:
  • Precision increased by an average of 27.7%.
  • Recall increased by an average of 42.7%.

Limitations and Future Work

The authors acknowledge a few caveats in their evaluation. First, the baseline comparison isn't perfectly "apples-to-apples": this paper analyzes code at the class level, whereas the baseline study looked at the broader component level. Additionally, the datasets differed slightly in scope.

For future work, the authors plan to validate their weighted network model across a wider variety of large-scale open-source and communication software projects to ensure its generalizability.

Summary updated

BibTeX
@inproceedings{wei2018vulnerability,
  author = {Shengjun Wei and Hao Zhong and Chun Shan and Lin Ye and Xiaojiang Du and Mohsen Guizani},
  title = {{Vulnerability Prediction Based on Weighted Software Network for Secure Software Building}},
  booktitle = {GLOBECOM},
  year = {2018},
  doi = {10.1109/glocom.2018.8647583},
}
Figure