TL;DR
This paper introduces ActiveClean, a novel active learning-based system that automatically generates high-quality, line-level vulnerability data from software commits. By intelligently selecting data points for human labeling, ActiveClean significantly reduces the manual effort required, leading to improved performance for state-of-the-art vulnerability detection tools.
What Problem Does This Paper Address?
Deep learning models are increasingly used for vulnerability detection in software, but their effectiveness hinges on large, high-quality training datasets. Existing datasets often provide only function-level labels (vulnerable or not), which is insufficient for pinpointing the exact lines of code responsible for a vulnerability. Manually creating line-level labels is extremely time-consuming and expensive. While static analysis tools can help clean commits, they rely on the accuracy of the tools themselves. This paper addresses the challenge of efficiently and accurately generating fine-grained, line-level vulnerability data from noisy software commits.
Methods
ActiveClean employs an active learning framework, specifically a query-by-committee approach, to tackle the data generation problem. The core idea is to train a machine learning model that can distinguish between vulnerability-relevant and irrelevant lines within code commits.
- Feature Engineering: The system extracts a rich set of syntactic and semantic features from commit lines and their surrounding code context. These features capture characteristics of individual lines, interactions between lines within a commit, and how commit lines interact with the broader codebase.
- Active Learning (Query-by-Committee): A committee of machine learning models is trained on a small initial set of labeled data. The active learning process then iteratively queries the committee to identify the most informative unlabeled data points for human labeling. This ensures that the model learns efficiently by focusing on the most ambiguous or uncertain examples.
- Label Generation: Once trained, ActiveClean can process new commits to generate line-level vulnerability labels. It can also identify potentially incorrect function-level labels in existing datasets.
Datasets
- Java Datasets: The paper utilized 17 Apache projects from a previously released dataset ([19]) which provided manually verified line-level ground truth labels for bug-fixing commits. This dataset comprised approximately 27K line-level labels across 365 commits.
- C Datasets: For C programs, the authors used FFmpeg and QEMU from the Devign dataset ([53]). Since Devign provides function-level labels, the authors manually inspected and labeled a subset of commits to create line-level ground truth for their experiments. This resulted in approximately 4.4K labels over 257 commits for C code.
- FFmpeg Project (Devign Dataset): ActiveClean was used to generate line-level labels for the entire FFmpeg project within the Devign dataset, covering 5K functions.
Key Insights and Ideas
- Commits are Noisy: The study highlights that software commits, even those intended for bug fixes, often contain a significant number of lines that are irrelevant to the actual vulnerability. Directly using these raw commits as training data for vulnerability detection models introduces substantial noise.
- Active Learning for Efficiency: Active learning is crucial for making the generation of line-level data feasible. By intelligently selecting data points to label, ActiveClean dramatically reduces the manual labeling effort compared to random sampling or full manual annotation.
- Feature Engineering is Key: The designed syntactic and semantic features are critical for the model to understand the nuances of code changes and differentiate between bug fixes and refactoring or unrelated modifications.
- Line-Level Data Boosts SOTA Tools: The generated line-level data significantly improves the performance of existing state-of-the-art vulnerability detection tools, demonstrating the practical impact of ActiveClean.
- Identifying Incorrect Labels: ActiveClean can effectively flag potentially mislabeled functions in existing datasets, contributing to the overall quality of vulnerability benchmarks.
Key Results
- High F1 Scores: ActiveClean achieved F1 scores between 70-74 across various datasets, demonstrating its effectiveness in cleaning commits and generating accurate line-level labels.
- Efficiency of Active Learning: Active learning proved highly efficient, with ActiveClean reaching an F1 score of 70.23 using only 400 additional training data points, whereas baseline models required significantly more data to achieve comparable or lower scores.
- Improved Vulnerability Detection: When the cleaned data generated by ActiveClean was used to train the state-of-the-art tool LineVul, it detected 70 more vulnerable lines and 18 more vulnerable functions, improving Top 10 accuracy from 66% to 73%.
- Label Correction: ActiveClean successfully identified incorrect function-level labels, with a sampled inspection confirming that 69.04% of recommended corrections were indeed valid.
Limitations and Future Work
- Limitations:
- The paper acknowledges that while ActiveClean achieves high F1 scores, it does not reach 100% accuracy and recall.
- The manual inspection and labeling process, even with active learning, still requires human effort.
- The performance on unseen C projects without retraining (e.g., QEMU) was lower (59.53 F1 score), indicating the need for some adaptation.
- Future Work:
- The authors plan to continuously apply ActiveClean to generate more line-level datasets for various projects.
- They aim to further report and correct false labels in existing vulnerability datasets.
- The potential of ActiveClean for other applications like automatic program repair and fault localization is also mentioned as a future direction.
Summary updated