NPM, an Ecosystem Full of Monsters ? The Dark Side of Lifecycle Scripts
Year: 2026
Type: preprint
Abstract: Software supply chain attacks increasingly target open-source package ecosystems. There, scripts provide an attractive vector for arbitrary code execution. The Node Package Manager (NPM) ecosystem is particularly exposed due to lifecycle scripts, and especially installation scripts, that are executed during package installation and are commonly used by malicious actors. While previous work did identify these installation scripts as a common attack vector, their predictive value and ecosystem-wide impact have not been systematically quantified and none of these works considered other type of scripts. In this paper, we aim at closing this gap. We conduct a large-scale empirical study of 3.56 million NPM packages and 8,001 confirmed malicious packages to characterize the relationship between package scripts and malicious behavior. We first measure the prevalence of all script types across the NPM ecosystem and compare their distribution with that of malicious packages. We then quantify the statistical association between each script type and maliciousness using relative risk and conditional probability analysis, before evaluating the transitive propagation of malicious packages through dependency relationships. Our results show that preinstall is by far the strongest indicator of malicious intent: a package declaring a preinstall script has a 29.9% probability of being malicious, with a relative risk of 427.9 compared with the general ecosystem. We further find that 43.8% of packages with dependencies transitively depend on at least one known malicious package, representing a potential exposure affecting more than 1,246,951 packages by transitive dependencies and over 1.1 trillion cumulative downloads. These findings provide quantitative evidence about scripts that constitute a major software supply chain risk, and support stronger restrictions or sandboxing of such scripts execution in package managers.
Source: HAL
Institution: DIVERSE: Diversity-centric Software Engineering
Language: English
Subfield: Information Systems
Field: Computer Science
Domain: Physical Sciences
Open Access status: green
OpenAlex ID: W7213479596
