CVMan: A Framework for Clone-Incurred Vulnerability Management

Jian Shi, Deqing Zou, Shouhuai Xu, Hai JinApplied Sciences 2023

TL;DR

This paper introduces CVMan, a novel framework for automatically managing vulnerabilities introduced by code clones. By analyzing both the spatial relationships between code fragments across different programs and their temporal evolution across software versions, CVMan provides a comprehensive view of clone-incurred risks. A case study on Ubuntu demonstrates the framework's ability to uncover key insights into clone prevalence and vulnerability distribution.

What Problem Does This Paper Address?

Modern software development heavily relies on code reuse, leading to a significant presence of code clones. While beneficial for efficiency, these clones can also propagate vulnerabilities, making it challenging to track and manage security risks. Existing research has focused on detecting clones or vulnerabilities separately, but there's a need for a unified approach to understand and manage the interplay between code clones and vulnerabilities. This paper addresses this gap by proposing a framework that specifically targets the management of vulnerabilities introduced and spread through code duplication.

Methods

The core of CVMan lies in its innovative use of two types of "clone-relation graphs":

  • Spatial Clone-Relation Graph (SCG): This graph captures clone relationships between code fragments within a single program or across different programs at a given point in time. It helps understand the "clone landscape" of a software system or a collection of systems.
  • Temporal Clone-Relation Graph (TCG): This graph extends the SCG by incorporating the evolution of clones over time, specifically across different versions of the same software. This allows for tracking how clones change and persist, providing a dynamic view of the clone landscape.

The framework also defines several metrics to quantify aspects of this landscape:

  • Clone Surface: The proportion of code in a program that is cloned.
  • Clone Prevalence: The number of times a specific code fragment appears as a clone.
  • Clone Lifetime: The duration (in terms of software versions) a cloned code fragment persists.

For vulnerability management, CVMan integrates with external vulnerability sources (like NVD, USN) to identify vulnerable code fragments. It then annotates the clone landscape with this vulnerability information, creating a "clone-incurred vulnerability landscape." This allows for identifying which cloned code is vulnerable and tracking its spread.

Datasets

The primary dataset used for the case study is Ubuntu, specifically analyzing eight versions of the operating system released between 2018 and 2021. The study focused on C/C++ programs within the main and universe repositories. The dataset comprised approximately 5760 programs and over 800 million lines of code in total. Vulnerability information was collected from sources like Ubuntu Security Notices (USN), Ubuntu CVE Tracker, and the National Vulnerability Database (NVD).

Key Insights and Ideas

  • Clones are Ubiquitous: The study found that approximately one-sixth of the codebase in Ubuntu consists of clones, highlighting the pervasive nature of code reuse.
  • Intra- vs. Inter-Program Clones: Intra-program clones (within a single program) are often due to functional similarities or polymorphism, while inter-program clones (across different programs) are typically a result of shared code repositories and library reuse.
  • Stable Clone Landscape: For Linux, the clone surface remained relatively stable around 0.6 across different versions, indicating that a significant portion of the codebase is consistently cloned.
  • Long-Lived Clones: A substantial portion (53%) of clones in Linux persisted across all eight analyzed versions, suggesting that many cloned code segments are fundamental and stable.
  • Small Vulnerable Clone Surface: Despite the prevalence of clones, the "clone-incurred vulnerability surface" in Linux was found to be small, suggesting that while clones exist, they don't necessarily amplify vulnerabilities to a large extent.
  • Similar Lifetimes for Vulnerable and Non-Vulnerable Clones: Interestingly, vulnerable clones and non-vulnerable clones exhibited similar lifetime distributions, implying that once a clone becomes vulnerable, it tends to persist for a similar duration as its non-vulnerable counterparts.

Key Results

  • Clone Prevalence: In Ubuntu 18.04, the SCG contained 337,837 nodes (code fragments) and 4,761,650 edges (clone relations). The clone surface for Ubuntu 18.04 was 0.18.
  • Linux TCG Analysis: For Linux, across eight versions, the TCG had 870,914 nodes and 5,073,824 edges. The clone surface for Linux remained stable around 0.6.
  • Vulnerability Mapping: Across eight Linux versions, 299 CVEs were matched, distributed across 310 files. For example, 473 nodes (procedures) in Ubuntu 18.04 contained vulnerable code.
  • Clone-Incurred Vulnerability Lifetime: 60% of vulnerable clones had a lifetime of 8 versions, indicating their persistence.

Limitations and Future Work

The authors acknowledge two main limitations:

  • Source Code Focus: The current framework is designed for source code. Extending it to handle binary code would be valuable for analyzing proprietary software where source code is unavailable. This would require binary-code-based clone detectors and methods to map source code patches to binary code.
  • Vulnerability Annotation Granularity: The current method for annotating vulnerable code fragments is conservative. A fragment is considered vulnerable if it shares any line with a vulnerable code fragment. Future work could explore more precise methods, such as identifying fragments that contain lines removed by a patch, to avoid false positives while ensuring comprehensive coverage.

The case study, while extensive, focused solely on Linux within Ubuntu. The authors suggest that further studies on other programs would be beneficial to ensure the generalizability of the insights.

Summary updated

BibTeX
@inproceedings{shi2023cvman,
  author = {Jian Shi and Deqing Zou and Shouhuai Xu and Hai Jin},
  title = {{CVMan: A Framework for Clone-Incurred Vulnerability Management}},
  booktitle = {Applied Sciences},
  year = {2023},
  doi = {10.3390/app13084948},
}
Figure