Automatic Diversity in the Software Supply Chain

Nicolas Harrand, Thomas Durieux, David Broman, Benoit BaudryarXiv 2021

Introduction

Modern software development increasingly resembles assembling a complex "Lego set" of external dependencies. While this modular approach significantly accelerates development cycles, it introduces a critical security bottleneck: the software monoculture. When thousands of applications rely on the exact same version of a popular third-party library, a single vulnerability in that dependency can compromise the entire ecosystem. High-profile incidents, such as the SolarWinds hack and the event-stream cryptocurrency theft, underscore the catastrophic potential of targeted supply chain attacks.

The Challenge of Client-Library Entanglement

The primary obstacle to diversifying the software supply chain is "client-library entanglement." Applications are typically tightly coupled to specific library APIs. Even when multiple libraries provide functionally equivalent features—such as parsing JSON or handling HTTP requests—their method signatures, data structures, and exception handling differ.

Decoupling libraries from their APIs using adapters to resolve client-library entanglement.

Manually substituting one library for another is a labor-intensive and error-prone process. This friction forces developers to stick with a single dependency, creating the very monoculture that attackers exploit. To address this, we need a way to automatically swap libraries without requiring manual code changes.

The Library Substitution Framework (LSF)

To break this entanglement, we propose the Library Substitution Framework (LSF), a three-tier adaptation architecture designed to enable automatic library swapping at build time. The framework consists of three distinct layers:

  1. The Bridge: Positioned at the top of the stack, the Bridge mimics the API of the original library (e.g., GSON). It intercepts calls from the application, making the substitution transparent to the client code.
  2. The Facade: This central, abstract layer captures the "core" features common to a specific category of libraries (the "reservoir"). By mapping every library to this central Facade rather than to every other library, we reduce the complexity of the adaptation effort from quadratic ($O(n^2)$) to linear ($O(n)$).
  3. The Wrapper: The Wrapper translates the abstract commands from the Facade into the specific implementation details of an alternative library (e.g., Jackson or fastjson).
The three-tier architecture of the Library Substitution Framework (LSF).

This architecture was implemented in a tool called ARGO, specifically targeting Java JSON libraries. ARGO utilizes Inversion of Control to swap these layers during the build process, allowing developers to generate multiple variants of an application, each utilizing a different backend library.

Experimental Methodology

The effectiveness of LSF and ARGO was evaluated using two primary datasets:

  • The Reservoir: A collection of 20 different Java JSON libraries sourced from Maven Central, ranging from industry standards like Jackson and GSON to specialized libraries like mjson.
  • The Clients: A set of 368 open-source Maven projects from GitHub that depend on one of the four most popular JSON libraries. These projects were selected based on the reproducibility of their builds and the presence of passing test suites, which served as the "ground truth" for behavioral equivalence.

A key insight driving this work is the "80/20 Rule of APIs." While many libraries possess extensive APIs, most client applications only utilize a small, common subset of features. This observation makes the creation of Bridges feasible, as developers only need to implement the most frequently used portions of the API.

Results and Impact

The study demonstrates that automated library diversity is not only possible but highly achievable in practice. Key findings include:

  • High Compatibility: 89.4% of the 368 tested applications compiled successfully when the original library was replaced by the ARGO bridge.
  • Massive Variation: The framework successfully generated 4,069 behaviorally correct application variants.
  • Interchangeability: For nearly 60% of the applications (195 projects), the original JSON library could be replaced by at least 15 different alternatives without breaking functionality.

These results suggest a significant leap in supply chain resilience. If a vulnerability is discovered in a specific library like GSON, a developer using ARGO could immediately generate and ship a version of their application using an alternative like Johnzon, mitigating the threat in minutes rather than days or weeks.

Limitations and Future Directions

While promising, the LSF approach faces several challenges. The framework relies heavily on the quality of existing test suites to serve as "oracles" for correctness. Weak test coverage might allow a substituted library to pass tests while failing in production edge cases. Additionally, "dependency hell"—where a new library introduces conflicting transitive dependencies—remains a hurdle.

Future work will explore extending this framework to more complex domains, such as cryptography or UI frameworks, where state management is more intricate. Furthermore, incorporating "performance-aware" substitution could help developers choose alternatives that meet specific CPU or memory constraints. By moving from a static to a dynamic software supply chain, we can build a more diverse and resilient digital infrastructure.

Summary updated

BibTeX
@misc{harrand2021automatic,
  author = {Nicolas Harrand and Thomas Durieux and David Broman and Benoit Baudry},
  title = {{Automatic Diversity in the Software Supply Chain}},
  year = {2021},
  eprint = {2111.03154},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.03154},
}
Figure