ResourcesResearchDemystifying the Vulnerability Propagation and Its Evolution via Dependency Trees in the NPM Ecosystem
research
Published on
September 18, 2024

Demystifying the Vulnerability Propagation and Its Evolution via Dependency Trees in the NPM Ecosystem

Written By
Ding Sun
Share

How can we effectively detect and mitigate known vulnerabilities in the NPM ecosystem to enhance the security and reliability of JavaScript applications?


We recently held an engaging interview with Chengwei Liu, the lead researcher behind "Demystifying the Vulnerability Propagation and Its Evolution via Dependency Trees in the NPM Ecosystem." Our conversation focused on the challenges posed by vulnerabilities in dependency trees and how innovative approaches like DTResolver and DTReme provide precise solutions. This important work was presented at ICSE 2022. Stay tuned for key insights and expert perspectives on improving security across the NPM ecosystem.

Scantist: Could you provide a brief overview of your research on vulnerability propagation in the NPM ecosystem? What motivated you to investigate this topic?

Chengwei Liu: Our research aimed to address a growing concern in the software industry: the hidden vulnerabilities that propagate through dependency trees in the NPM ecosystem. With over 1.7 million Node.js libraries available, developers often rely on third-party packages, which can introduce severe security risks. Existing tools and research mostly focused on direct dependencies, but transitive dependencies were being neglected. Motivated by the increasing complexity of NPM’s dependency structures, we developed a precise method to analyze and track how vulnerabilities propagate, to improve security management across the ecosystem.

Scantist: Can you describe the key challenges in analyzing vulnerabilities in the NPM ecosystem before your study?

Chengwei Liu: The key challenges included the complexity of NPM’s dependency resolution rules, which are unique and dynamic. Existing approaches often failed to account for these rules, leading to inaccurate results, particularly in analyzing transitive dependencies. Additionally, the NPM ecosystem evolves rapidly, with new vulnerabilities being introduced over time as packages are updated. The sheer scale of the ecosystem, involving millions of packages and versions, also posed difficulties in conducting large-scale, precise analyses. Tools available before our work either lacked efficiency or accuracy, failing to comprehensively capture how vulnerabilities propagate.

Scantist: In your study, you explored how vulnerabilities propagate via dependency trees. How does the use of third-party libraries amplify these security risks, particularly with transitive dependencies?

Chengwei Liu: Third-party libraries in the NPM ecosystem, while efficient, introduce severe security risks when transitive dependencies come into play. Our findings revealed that vulnerabilities are not confined to direct dependencies; they propagate deeply through transitive ones, often unnoticed. About 25% of all library versions we analyzed were affected by vulnerabilities, including critical vulnerabilities in some of the most used packages. As developers frequently rely on these third-party libraries, they inadvertently expose their applications to a higher risk of being compromised, especially if transitive vulnerabilities are overlooked during dependency resolution.

Scantist: Could you explain the significance of your findings that "vulnerabilities widely exist in the dependencies of NPM packages" and how this impacts developers using the ecosystem?

Chengwei Liu: Our research highlighted that nearly 24.78% of NPM packages are affected by vulnerabilities due to dependencies, even when developers update to the latest versions. This poses a significant risk as developers often assume that keeping dependencies updated will mitigate security concerns. However, our findings show that even recent versions can propagate vulnerabilities from older, transitive dependencies. This affects developers by creating a false sense of security and emphasizing the need for tools that analyze the entire dependency tree, rather than just focusing on direct dependencies.

Scantist : Your research also looked into how vulnerability propagation evolves over time. How do dependency tree changes influence the vulnerability status of a root package?

Chengwei Liu: Dependency trees are dynamic and evolve as new library versions are released, which can either introduce or resolve vulnerabilities. Our study found that vulnerabilities propagate through these evolving trees, impacting root packages even if the developers maintain their dependencies. Over time, more vulnerable paths emerge, increasing the likelihood of root packages becoming compromised. For example, even if a package is initially secure, updates to its dependencies could introduce vulnerabilities. This dynamic evolution makes it difficult to maintain secure packages without constant monitoring and analysis of the entire dependency chain.

Scantist: You found that the majority of vulnerabilities (93%) are introduced before they are even discovered. How do these findings reflect the challenges in maintaining secure dependencies over time?

Chengwei Liu: Our findings showed that 93% of vulnerabilities were introduced into dependency trees before they were officially discovered. This presents a major challenge for maintaining secure dependencies, as developers often remain unaware of the risks posed by their dependencies until it’s too late. The delays in discovering vulnerabilities mean that many packages are exposed for extended periods, allowing attackers to exploit these weaknesses. Even after discovery, fixing these vulnerabilities across transitive dependencies takes significant time, requiring faster identification tools and better dependency management practices to ensure timely remediation.

Scantist: Based on your findings, what are some practical steps that package maintainers and consumers can take to mitigate vulnerability propagation in the NPM ecosystem?

Chengwei Liu: To mitigate vulnerability propagation, package maintainers should prioritize the regular release of patch versions and ensure that older versions, especially those widely used, are decommissioned or updated. For consumers, adopting tools like DTReme that provide more precise remediation than existing solutions, such as npm audit fix, is essential. Additionally, developers should avoid fixed version dependencies, as these prevent packages from receiving critical updates. Routine audits of direct and transitive dependencies, combined with a proactive approach to managing vulnerabilities, are also vital in reducing exposure to security risks.

Scantist: What future directions do you foresee for research in addressing the growing complexity of vulnerability management in large ecosystems like NPM?

Chengwei Liu: Future research should focus on developing more advanced tools for real-time vulnerability detection and automated remediation across large-scale ecosystems like NPM. There is also a need for enhanced static and dynamic analysis techniques that can more accurately track vulnerable paths and dependencies in real-world applications. Moreover, deeper collaboration between package maintainers and users is required to ensure faster identification and resolution of vulnerabilities. Integrating these findings with machine learning models that can predict vulnerability risks could further enhance the security of software ecosystems.