NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Automated software vulnerability detection with machine learning

Jacob A. Harer, Louis Y. Kim, Rebecca L. Russell, Onur Ozdemir, Leonard R. Kosta, Akshay Rangamani, Lei H. Hamilton, Gabriel I. Centeno, Jonathan R. Key, Paul M. Ellingwood, Marc W. McConley, Jeffrey M. Opper, Peter Chin, Tomo LazovicharXiv 2018

Introduction

Software vulnerabilities represent critical security risks, often leading to large-scale data breaches and system exploits. Traditional detection methods—manual code review and rule-based static analysis—face significant scalability challenges as open-source repositories grow exponentially. This research explores a shift from rule-based systems to data-driven machine learning models capable of identifying the "statistical smell" of a bug across millions of lines of code.

Methodology: Representing Code for Machines

The core challenge in applying machine learning to software security is feature engineering: how do we represent complex C/C++ code in a format a model can process? This study evaluated two primary approaches.

Build-based Features

This method focuses on the structural artifacts generated during compilation. Using Clang/LLVM, the researchers extracted Control Flow Graphs (CFGs), which map every potential execution path within a function. These graphs are then converted into adjacency matrices and combined with operation codes (opcodes) and "use-def" matrices to track variable lifecycles.

Extraction of build-based features: mapping source code to basic blocks and a Control Flow Graph (CFG) represented as an adjacency matrix.

Source-based Features

Alternatively, code can be treated as a form of natural language. A custom lexer decomposes the raw source code into tokens—such as keywords, variable names, and operators. These tokens are then transformed into numerical vectors using Word2Vec embeddings or Bag-of-Words counts.

The tokenization process for source-based features, where code is parsed into discrete lexical units.

Model Architecture and Training

The researchers utilized a massive dataset of over 750,000 C/C++ functions harvested from Debian packages and GitHub repositories. To establish "ground truth," the Clang Static Analyzer was used to label functions as either "buggy" or "clean."

The study compared traditional classifiers like Extra-Trees with deep learning architectures such as TextCNN. The most effective approach proved to be a hybrid model: a Convolutional Neural Network (CNN) extracts high-level features from the code tokens, which are then fed into an Extra-Trees classifier for final vulnerability prediction.

Key Findings

  • Source Code Superiority: Surprisingly, models trained on raw source code outperformed those using structured build artifacts. This suggests that human-centric coding patterns—naming conventions and stylistic choices—provide vital clues for vulnerability detection that are lost during compilation.
  • Semantic Learning: Without prior knowledge of C++ syntax, the Word2Vec embeddings successfully clustered related concepts, such as grouping data types (int, char) and memory management functions (malloc, free).
  • Performance Metrics: The best-performing hybrid model achieved an Area Under the ROC Curve (AUC) of 0.87, demonstrating strong generalization across both curated (Debian) and "wild" (GitHub) datasets.

Limitations and Future Directions

The primary constraint of this approach is the "Oracle Problem." Since the models are trained on labels generated by a static analyzer, they are inherently limited to detecting the same classes of bugs as the original tool. Future work aims to incorporate real-world CVE data and bug reports to move beyond these limitations. Additionally, expanding the scope from individual functions to inter-procedural analysis will be necessary to detect complex vulnerabilities like use-after-free errors.

The ultimate vision for this research is not only automated detection but automated repair—moving from identifying flaws to suggesting secure code corrections.

Summary updated

BibTeX
@misc{harer2018automated,
  author = {Jacob A. Harer and Louis Y. Kim and Rebecca L. Russell and Onur Ozdemir and Leonard R. Kosta and Akshay Rangamani and Lei H. Hamilton and Gabriel I. Centeno and Jonathan R. Key and Paul M. Ellingwood and Marc W. McConley and Jeffrey M. Opper and Peter Chin and Tomo Lazovich},
  title = {{Automated software vulnerability detection with machine learning}},
  year = {2018},
  eprint = {1803.04497},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1803.04497},
}
Figure