Leveraging Large Language Models to Detect npm Malicious Packages
Not on the map. Why?
Abstract (arXiv)
Existing malicious code detection techniques demand the integration of multiple tools to detect different malware patterns, often suffering from high misclassification rates. Therefore, malicious code detection techniques could be enhanced by adopting advanced, more automated approaches to achieve high accuracy and a low misclassification rate. The goal of this study is to aid security analysts in detecting malicious packages by empirically studying the effectiveness of Large Language Models (LLMs) in detecting malicious code. We present SocketAI, a malicious code review workflow to detect malicious code. To evaluate the effectiveness of SocketAI, we leverage a benchmark dataset of 5,115 npm packages, of which 2,180 packages have malicious code. We conducted a baseline comparison of GPT-3 and GPT-4 models with the state-of-the-art CodeQL static analysis tool, using 39 custom CodeQL rules developed in prior research to detect malicious Javascript code. We also compare the effectiveness of static analysis as a pre-screener with SocketAI workflow, measuring the number of files that need to be analyzed. and the associated costs. Additionally, we performed a qualitative study to understand the types of malicious activities detected or missed by our workflow. Our baseline comparison demonstrates a 16% and 9% improvement over static analysis in precision and F1 scores, respectively. GPT-4 achieves higher accuracy with 99% precision and 97% F1 scores, while GPT-3 offers a more cost-effective balance at 91% precision and 94% F1 scores. Pre-screening files with a static analyzer reduces the number of files requiring LLM analysis by 77.9% and decreases costs by 60.9% for GPT-3 and 76.1% for GPT-4. Our qualitative analysis identified data theft, execution of arbitrary code, and suspicious domain categories as the top detected malicious packages.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 28 of its 56 references that are in the map. First posted on arXiv 18 Mar 2024.
Builds on
28 of 56 references.
References · 28
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,393
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2022Survey of Hallucination in Natural Language Generationcited by 2,056
- 2023A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPTcited by 612
- 2023Is ChatGPT a General-Purpose Natural Language Processing Task Solver?cited by 486
- 2023Harnessing the Power of LLMs in Practice: A Survey on ChatGPT and Beyondcited by 409
- 2023The Curse of Recursion: Training on Generated Data Makes Models Forgetcited by 343
- 2023Better Zero-Shot Reasoning with Role-Play Promptingcited by 220
- 2023Can ChatGPT Understand Too? A Comparative Study on ChatGPT and Fine-tuned BERTcited by 155
- 2023Summary of ChatGPT-Related Research and Perspective Towards the Future of Large Language Modelscited by 152
16 more
- 2023An Analysis of the Automatic Bug Fixing Performance of ChatGPTcited by 108
- 2023Large Language Models Suffer From Their Own Output: An Analysis of the Self-Consuming Training Loopcited by 75
- 2023Automatic Semantic Augmentation of Language Model Prompts (for Code Summarization)cited by 72
- 2023ChatGPT Prompt Patterns for Improving Code Quality, Refactoring, Requirements Elicitation, and Software Designcited by 66
- 2020Backstabber's Knife Collection: A Review of Open Source Software Supply Chain Attackscited by 57
- 2023Prompt Engineering a Prompt Engineercited by 53
- 2023PREFER: Prompt Ensemble Learning via Feedback-Reflect-Refinecited by 28
- 2024Detecting Mode Collapse in Language Models via Narrationcited by 24
- 2023An Empirical Study of Malicious Code In PyPI Ecosystemcited by 18
- 2021What are Weak Links in the npm Supply Chain?cited by 16
- 2023An Empirical Study on Using Large Language Models to Analyze Software Supply Chain Security Failurescited by 11
- 2022Practical Automated Detection of Malicious npm Packagescited by 7
- 2022A Benchmark Comparison of Python Malware Detection Approachescited by 7
- 2020SpellBound: Defending Against Package Typosquattingcited by 4
- 2021Anomalicious: Automated Detection of Anomalous and Potentially Malicious Commits on GitHubcited by 4
- 2022Towards the Detection of Malicious Java Packagescited by 2
Built on by
Citing papers per year: 2024: 1; 2025: 3; 2026: 2.
6 papers.
- 2024Probing the limitations of multimodal language models for chemistry and materials researchcited by 31
- 2025A Contemporary Survey of Large Language Model Assisted Program Analysiscited by 10
- 2025LLM-Based Identification of Infostealer Infection Vectors from Screenshots: The Case of Auroracited by 0
- 2025One Detector Fits All: Robust and Adaptive Detection of Malicious Packages from PyPI to Enterprisescited by 0
- 2026CHASE: LLM Agents for Dissecting Malicious PyPI Packagescited by 0
- 2026MOLOT System Card: Malicious Operational Logic Observation Transformercited by 0
- 2026MOLOT System Card: Malicious Operational Logic Observation Transformer5 Jun 2026
- 2026CHASE: LLM Agents for Dissecting Malicious PyPI Packages11 Jan 2026
- 2025One Detector Fits All: Robust and Adaptive Detection of Malicious Packages from PyPI to Enterprises3 Dec 2025
- 2025LLM-Based Identification of Infostealer Infection Vectors from Screenshots: The Case of Aurora31 Jul 2025
- 2025A Contemporary Survey of Large Language Model Assisted Program Analysis5 Feb 2025
- 2024Probing the limitations of multimodal language models for chemistry and materials research25 Nov 2024