Lune

ICSE2022Top-tier venue

Practical Automated Detection of Malicious npm Packages

Adriana Sejfia, Max Schäfer

Abstract

The npm registry is one of the pillars of the JavaScript and Type-Script ecosystems, hosting over 1.7 million packages ranging from simple utility libraries to complex frameworks and entire applications. Each day, developers publish tens of thousands of updates as well as hundreds of new packages. 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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

24 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Containing Malicious Package Updates in npm with a Lightweight Permission System cites Small World with High Risks: A Study of Security Threats in the npm Ecosystem
  • Bad Snakes: Understanding and Improving Python Package Index Malware Scanning cites LastPyMile: identifying the discrepancy between sources and packages
  • Bad Snakes: Understanding and Improving Python Package Index Malware Scanning cites Towards Measuring Supply Chain Attacks on Package Managers for Interpreted Languages
  • DONAPI: Malicious NPM Packages Detector using Behavior Sequence Knowledge Mapping cites Containing Malicious Package Updates in npm with a Lightweight Permission System
  • DONAPI: Malicious NPM Packages Detector using Behavior Sequence Knowledge Mapping cites Towards Measuring Supply Chain Attacks on Package Managers for Interpreted Languages
  • DONAPI: Malicious NPM Packages Detector using Behavior Sequence Knowledge Mapping cites Small World with High Risks: A Study of Security Threats in the npm Ecosystem
  • LastPyMile: identifying the discrepancy between sources and packages cites Containing Malicious Package Updates in npm with a Lightweight Permission System
  • LastPyMile: identifying the discrepancy between sources and packages cites Towards Measuring Supply Chain Attacks on Package Managers for Interpreted Languages
  • LastPyMile: identifying the discrepancy between sources and packages cites Small World with High Risks: A Study of Security Threats in the npm Ecosystem
  • Towards Measuring Supply Chain Attacks on Package Managers for Interpreted Languages cites Small World with High Risks: A Study of Security Threats in the npm Ecosystem
  • Malicious Package Detection using Metadata Information cites Small World with High Risks: A Study of Security Threats in the npm Ecosystem
  • Modular call graph construction for security scanning of Node.js applications cites Small World with High Risks: A Study of Security Threats in the npm Ecosystem
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers24

  1. BOMs Away! Inside the Minds of Stakeholders: A Comprehensive Study of Bills of Materials for Software SystemsTrevor Stalnaker, Nathan Wintersgill, Oscar Chaparro, Massimiliano Di Penta et al.ICSE 2024 · 50 citations
  2. DONAPI: Malicious NPM Packages Detector using Behavior Sequence Knowledge MappingCheng Huang, Nannan Wang, Ziyan Wang, Siqi Sun et al.USENIX Security 2024 · 38 citations
  3. Malicious Package Detection using Metadata InformationSajal Halder, Michael Bewong, Arash Mahboubi, Yinhao Jiang et al.WWW 2024 · 23 citations
  4. Bad Snakes: Understanding and Improving Python Package Index Malware ScanningDuc-Ly Vu, Zachary Newman, John Speed MeyersICSE 2023 · 18 citations
  5. Not All Dependencies are Equal: An Empirical Study on Production Dependencies in NPMJasmine Latendresse, Suhaib Mujahid, Diego Elias Costa, Emad ShihabASE 2022 · 17 citations

Builds on5

  1. Small World with High Risks: A Study of Security Threats in the npm EcosystemMarkus Zimmermann, Cristian-Alexandru Staicu, Cam Tenny, Michael PradelUSENIX Security 2019 · 281 citations
  2. LastPyMile: identifying the discrepancy between sources and packagesDuc-Ly Vu, Fabio Massacci, Ivan Pashchenko, Henrik Plate et al.FSE 2021 · 53 citations
  3. Modular call graph construction for security scanning of Node.js applicationsBenjamin Barslev Nielsen, Martin Toldam Torp, Anders MøllerISSTA 2021 · 47 citations
  4. Containing Malicious Package Updates in npm with a Lightweight Permission SystemGabriel Ferreira, Limin Jia, Joshua Sunshine, Christian KästnerICSE 2021 · 3 citations
  5. Towards Measuring Supply Chain Attacks on Package Managers for Interpreted LanguagesRuian Duan, Omar Alrawi, Ranjita Pai Kasturi, Ryan Elder et al.NDSS 2021

Related papers

  1. ProfMal: Detecting Malicious NPM Packages by the Synergy between Static and Dynamic AnalysisYiheng Huang, Wen Zheng, Susheng Wu, Bihuan Chen et al.ASE 2025 · 2 citations
  2. Maltracker: A Fine-Grained NPM Malware Tracker Copiloted by LLM-Enhanced DatasetZeliang Yu, Ming Wen, Xiaochen Guo, Hai JinISSTA 2024 · 16 citations
  3. SpiderScan: Practical Detection of Malicious NPM Packages Based on Graph-Based Behavior Modeling and MatchingYiheng Huang, Ruisi Wang, Wen Zheng, Zhuotong Zhou et al.ASE 2024 · 4 citations
  4. What the Fork? Finding Hidden Code Clones in npmElizabeth Wyss, Lorenzo De Carli, Drew DavidsonICSE 2022 · 10 citations
  5. Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining FrameworkWenbo Guo, Chengwei Liu, Ming Kang, Yiran Zhang et al.USENIX Security 2026 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines