Which Is Better For Reducing Outdated and Vulnerable Dependencies: Pinning or Floating?

Imranur Rahman, Jill Marley, William Enck, Laurie A. WilliamsASE 2025

TL;DR

This paper empirically investigates whether "pinning" dependencies (locking to a specific version) or "floating" them (allowing updates within a range) is better for reducing outdated and vulnerable dependencies. They found that floating-major is least likely to result in outdated dependencies, while floating-minor is most likely to result in vulnerable ones, recommending a hybrid approach with lockfiles.

What Problem Does This Paper Address?

In software development, managing dependencies is crucial. Developers specify version constraints to ensure their projects use compatible versions of external libraries. "Pinning" locks a dependency to a single version, preventing breaking changes but also hindering automatic updates for bug fixes and security patches. "Floating" allows dependencies to be updated within a specified range, enabling automatic updates but risking breaking changes or the adoption of malicious code. Security practitioners often advocate for pinning to prevent supply chain attacks, yet this can lead to outdated and potentially vulnerable dependencies. This paper aims to provide empirical evidence to help developers make informed choices about dependency version constraints by evaluating their impact on outdatedness and vulnerability at scale.

Methods

The researchers employed a multi-faceted approach:

  • Data Collection: They gathered package metadata (dependency relationships, version releases) from three major ecosystems: npm, PyPI, and Cargo, using the deps.dev platform. They also collected security advisories (CVE data) from the CISA OSV database.
  • Dependency Resolution: A key methodological contribution is the use of historical dependency resolution, simulating how packages would have resolved dependencies at specific points in time. This was crucial for analyzing state transitions.
  • Survival Analysis: To quantify the time to becoming outdated or vulnerable, they used Cox proportional hazards models. This statistical technique allows for the analysis of time-to-event data and the estimation of hazard ratios, indicating the relative risk of an event occurring under different conditions. They specifically used time-varying Cox models to account for changes in constraint types over time.
  • Categorization of Version Constraints: They defined a fine-grained taxonomy of version constraint types (e.g., pinning, floating-patch, floating-minor, floating-major, fixed-ranging, etc.) to analyze their distinct impacts.

Datasets

  • Package Metadata: Data from deps.dev for npm, PyPI, and Cargo ecosystems. Initially, this included over 3 million packages, which was filtered down to over 160,000 unique dependencies for the survival analysis.
  • Security Advisories: CVE data from the CISA OSV database for npm, PyPI, and Cargo.
  • SourceRank Scores: Data from libraries.io was used to filter for top packages in each ecosystem for certain analyses.

Key Insights and Ideas

  • Floating-Major is King for Freshness: Dependencies using floating-major constraints are significantly less likely to become outdated. This makes intuitive sense, as it allows for the adoption of any new release, including major ones.
  • Pinning Isn't Always Secure: While often recommended for security, pinning doesn't guarantee safety. The study found that pinning can lead to more outdated dependencies, and the security benefits are not as clear-cut as often assumed.
  • Floating-Minor is a Double-Edged Sword: It's the most common constraint type and is associated with a higher likelihood of becoming vulnerable. This suggests that while it facilitates security updates, these fixes aren't always backported effectively across all major versions, leaving projects vulnerable.
  • Constraint Type Changes Matter: Developers frequently change version constraints, and the way they change them (e.g., moving from pinning to floating) has a direct impact on dependency states.
  • Lockfiles are Essential: The paper strongly recommends using lockfiles in conjunction with floating constraints to mitigate the risks of breaking changes while still benefiting from automatic updates.

Key Results

  • RQ1 (Frequency): floating-minor is the most common constraint type in npm and Cargo, followed by pinning. In PyPI, floating-major is most common.
  • RQ1 (Outdated/Vulnerable): floating-minor and pinning account for the majority of outdated and vulnerable dependency occurrences. floating-minor is over-represented in outdated and vulnerable dependencies in Cargo, while pinning is over-represented in outdated and vulnerable dependencies in PyPI.
  • RQ2 (Changes): Developers most frequently change version constraints without changing the constraint type. However, changes involving type shifts (e.g., pinning to floating) are also significant. Moving from pinning to more flexible types is common when updating.
  • RQ3 (Survival Analysis):
    • Outdatedness: floating-major has the lowest hazard ratio (0.01), meaning it's least likely to result in outdated dependencies. or-expression has the highest hazard ratio (1.94), making it most likely to result in outdated dependencies.
  • Vulnerability: floating-minor has a hazard ratio of 0.57, indicating it's less likely to result in vulnerability than pinning. Conversely, fixed-ranging (2.69) and complex-expression (3.52) have higher hazard ratios for vulnerability.

Limitations and Future Work

  • External Validity: The study focused on npm, PyPI, and Cargo. Generalizing to other ecosystems might require further investigation.
  • Vulnerability Severity: The study treated all vulnerabilities equally, without considering their severity (e.g., CVSS scores).
  • Dev Intent: The authors acknowledge that the developers' intent behind changing constraint types is not fully understood and suggests future research to uncover these intentions.
  • Exclusion of Dev/Optional Dependencies: The analysis focused only on runtime dependencies.
  • Future Work: The authors suggest extending the study to other ecosystems, incorporating vulnerability severity, and developing metrics to assess the risk of using a package as a dependency based on its constraint type usage. They also propose exploring developers' intentions behind constraint changes.

Summary updated

BibTeX
@inproceedings{rahman2025which,
  author = {Imranur Rahman and Jill Marley and William Enck and Laurie A. Williams},
  title = {{Which Is Better For Reducing Outdated and Vulnerable Dependencies: Pinning or Floating?}},
  booktitle = {ASE},
  year = {2025},
}
Figure