Practical Automated Detection of Malicious npm Packages
Not on the map. Why?
Abstract (arXiv)
The npm registry is one of the pillars of the JavaScript and TypeScript ecosystems, hosting over 1.7 million packages ranging from simple utility libraries to complex frameworks and entire applications. Due to the overwhelming popularity of npm, it has become a prime target for malicious actors, who publish new packages or compromise existing packages to introduce malware that tampers with or exfiltrates sensitive data from users who install either these packages or any package that (transitively) depends on them. Defending against such attacks is essential to maintaining the integrity of the software supply chain, but the sheer volume of package updates makes comprehensive manual review infeasible. We present Amalfi, a machine-learning based approach for automatically detecting potentially malicious packages comprised of three complementary techniques. We start with classifiers trained on known examples of malicious and benign packages. If a package is flagged as malicious by a classifier, we then check whether it includes metadata about its source repository, and if so whether the package can be reproduced from its source code. Packages that are reproducible from source are not usually malicious, so this step allows us to weed out false positives. Finally, we also employ a simple textual clone-detection technique to identify copies of malicious packages that may have been missed by the classifiers, reducing the number of false negatives. Amalfi improves on the state of the art in that it is lightweight, requiring only a few seconds per package to extract features and run the classifiers, and gives good results in practice: running it on 96287 package versions published over the course of one week, we were able to identify 95 previously unknown malware samples, with a manageable number of false positives.
Key facts. Cited by 7 papers in the map (data through 7 Oct 2026). First posted on arXiv 28 Feb 2022.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 3; 2025: 0; 2026: 4.
7 papers.
- 2024Leveraging Large Language Models to Detect npm Malicious Packagescited by 6
- 2024A Survey of Source Code Representations for Machine Learning-Based Cybersecurity Taskscited by 4
- 2026SkillGate: Cost Efficient Runtime Malicious Skill File Detection in Coding Agentscited by 2
- 2024SoK: A Systems Perspective on Compound AI Threats and Countermeasurescited by 1
- 2026CHASE: LLM Agents for Dissecting Malicious PyPI Packagescited by 0
- 2026LLM-Enhanced Hierarchical Heterogeneous Graph Representation Learning for Malicious Python Package Detectioncited by 0
- 2026From Adoption to Deployment: A Qualitative Study on AI Integration in Software Development Practicecited by 0
- 2026SkillGate: Cost Efficient Runtime Malicious Skill File Detection in Coding Agents28 Jul 2026
- 2026From Adoption to Deployment: A Qualitative Study on AI Integration in Software Development Practice18 Jul 2026
- 2026LLM-Enhanced Hierarchical Heterogeneous Graph Representation Learning for Malicious Python Package Detection3 Jul 2026
- 2026CHASE: LLM Agents for Dissecting Malicious PyPI Packages11 Jan 2026
- 2024SoK: A Systems Perspective on Compound AI Threats and Countermeasures20 Nov 2024
- 2024Leveraging Large Language Models to Detect npm Malicious Packages18 Mar 2024
- 2024A Survey of Source Code Representations for Machine Learning-Based Cybersecurity Tasks15 Mar 2024