mlsanityData to 7 Oct 2026

Leveraging Large Language Models to Detect npm Malicious Packages

arXiv 2403.12196 ↗First posted 18 Mar 2024cs.CR cs.AIcited by 6

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

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  3. 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,393
  4. 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
  5. 2022Survey of Hallucination in Natural Language Generationcited by 2,056
  6. 2023A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPTcited by 612
  7. 2023Is ChatGPT a General-Purpose Natural Language Processing Task Solver?cited by 486
  8. 2023Harnessing the Power of LLMs in Practice: A Survey on ChatGPT and Beyondcited by 409
  9. 2023The Curse of Recursion: Training on Generated Data Makes Models Forgetcited by 343
  10. 2023Better Zero-Shot Reasoning with Role-Play Promptingcited by 220
  11. 2023Can ChatGPT Understand Too? A Comparative Study on ChatGPT and Fine-tuned BERTcited by 155
  12. 2023Summary of ChatGPT-Related Research and Perspective Towards the Future of Large Language Modelscited by 152
16 more
  1. 2023An Analysis of the Automatic Bug Fixing Performance of ChatGPTcited by 108
  2. 2023Large Language Models Suffer From Their Own Output: An Analysis of the Self-Consuming Training Loopcited by 75
  3. 2023Automatic Semantic Augmentation of Language Model Prompts (for Code Summarization)cited by 72
  4. 2023ChatGPT Prompt Patterns for Improving Code Quality, Refactoring, Requirements Elicitation, and Software Designcited by 66
  5. 2020Backstabber's Knife Collection: A Review of Open Source Software Supply Chain Attackscited by 57
  6. 2023Prompt Engineering a Prompt Engineercited by 53
  7. 2023PREFER: Prompt Ensemble Learning via Feedback-Reflect-Refinecited by 28
  8. 2024Detecting Mode Collapse in Language Models via Narrationcited by 24
  9. 2023An Empirical Study of Malicious Code In PyPI Ecosystemcited by 18
  10. 2021What are Weak Links in the npm Supply Chain?cited by 16
  11. 2023An Empirical Study on Using Large Language Models to Analyze Software Supply Chain Security Failurescited by 11
  12. 2022Practical Automated Detection of Malicious npm Packagescited by 7
  13. 2022A Benchmark Comparison of Python Malware Detection Approachescited by 7
  14. 2020SpellBound: Defending Against Package Typosquattingcited by 4
  15. 2021Anomalicious: Automated Detection of Anomalous and Potentially Malicious Commits on GitHubcited by 4
  16. 2022Towards the Detection of Malicious Java Packagescited by 2

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 1; 2025: 3; 2026: 2.

6 papers.