Noisy Label Learning for Security Defects

Roland Croft, Muhammad Ali Babar, Huaming Chen

Abstract

In software vulnerability prediction (SVP), the reliability of ground truth labels is often compromised by latent vulnerabilities—defects that exist in the code but have not yet been discovered or reported. This study, originally presented at MSR '22, investigates the impact of "noisy labels" on SVP models and evaluates the efficacy of Noisy Label Learning (NLL) techniques. By applying these methods to a curated dataset of Mozilla Firefox releases, the researchers demonstrate that automated noise-cleaning can significantly improve predictive performance, specifically increasing AUC by nearly 9% and recall by over 23%.

Introduction

The efficacy of machine learning models is fundamentally limited by the quality of their training data. In the domain of software security, this "Garbage In, Garbage Out" principle is particularly problematic. Standard datasets for Software Vulnerability Prediction (SVP) typically categorize code modules as either "vulnerable" or "clean." However, a "clean" label often indicates the absence of a known vulnerability rather than the absence of any defect. These latent vulnerabilities introduce semantic noise into the dataset, confusing classifiers and degrading their ability to distinguish between secure and insecure code.

Manual verification of labels is prohibitively expensive; for instance, auditing a small subset of the Firefox codebase can require over 100 hours of expert labor. This paper explores whether automated Noisy Label Learning (NLL) can mitigate the impact of this noise without the need for exhaustive human intervention.

The Nature of Label Noise in Security

The researchers analyzed Mozilla Firefox (releases 63 to 84), creating a "gold standard" dataset of 211,658 files. By tracing future security patches back to their origin, they identified both latent vulnerabilities and "silent fixes"—patches that addressed security issues without being explicitly labeled as such in commit logs.

The study revealed that noise in security data is not random (symmetric) but instance-dependent. Latent vulnerabilities were found to be three times more prevalent than reported ones. Furthermore, certain types of defects, such as Buffer Overflows and Use-After-Free errors, exhibited high "latency," remaining hidden for an average of over 200 days. These bugs were also found to cluster in specific "hotspots," such as the media/ and ipc/ (inter-process communication) directories.

Methodology: Noisy Label Learning (NLL)

To address this noise, the authors evaluated several NLL strategies designed to identify and remediate mislabeled samples during the training process:

  1. Confident Learning: This technique employs cross-validation to estimate the probability of label noise. It identifies instances where the model's prediction confidence strongly contradicts the assigned label, subsequently pruning those samples or flipping their labels.
  2. Multi-Stage Learning: This approach relies on the "smoothness assumption"—the idea that code with similar feature embeddings should share the same label.
  3. 1-Stage: This method identifies "reliable negatives" (clean samples mathematically distant from known vulnerabilities) and prunes all other uncertain samples.
  4. 2-Stage: This more sophisticated approach uses reliable negatives and known positives to train an initial classifier. This classifier then re-labels uncertain samples before the final model is trained.
  5. Post-Processing: This method adjusts the output probabilities of a trained model to better align with the actual distribution of vulnerabilities in a real-world environment.

The underlying architecture utilized CodeBERT for generating vector embeddings of source code, which were then processed by a Random Forest classifier.

Experimental Results

The experiments demonstrated that accounting for label noise is critical for high-performance SVP. The 2-Stage Learning method emerged as the most effective strategy:

  • AUC Improvement: The model achieved a mean AUC of 0.773, representing an 8.9% improvement over the baseline model trained on noisy data.
  • Recall Gains: Recall for reported vulnerabilities increased by 23.4%, indicating a significantly higher success rate in identifying actual defects.
  • The Performance Gap: Despite these gains, a gap remains between NLL-enhanced models and a "Semi-Optimal" scenario (AUC 0.886) where the model has perfect knowledge of all latent bugs. This suggests that while NLL mitigates noise, it does not entirely eliminate its impact.

Limitations and Future Directions

While NLL techniques improve overall model robustness, they face several challenges:

  • Precision: The methods are more effective at "cleaning" the training set than they are at precisely identifying which specific files are noisy.
  • Class Imbalance: Vulnerabilities typically constitute less than 1% of a dataset. NLL techniques often struggle when the noise resides within such a small minority class.
  • Granularity: This study focused on file-level predictions. Future research is needed to apply these techniques at the function or line level, where noise may be even more prevalent.

Conclusion

The findings of Croft et al. highlight that latent vulnerabilities are a dominant factor in security datasets. By adopting Noisy Label Learning—particularly multi-stage approaches—researchers and practitioners can build more resilient vulnerability predictors that better handle the inherent messiness of real-world software data.

Summary updated

BibTeX
@inproceedings{croft2022noisy,
  author = {Roland Croft and Muhammad Ali Babar and Huaming Chen},
  title = {{Noisy Label Learning for Security Defects}},
  booktitle = {MSR},
  year = {2022},
}
Figure