paperbot · PL 论文追踪

全部论文 待读 收藏

P1 Leveraging Large Language Models to Detect NPM Malicious Packages

利用大型语言模型检测 NPM 恶意包
ICSE 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE)2025匹配度 5/10 · 论文属于「LLM 与静态分析协同」的交叉方向,把 CodeQL 静态分析作为预筛器降低 LLM 成本,与用户关注的 AI→PL 有交集;但其目标是 npm 恶意包检测这一安全任务,并非改进静态分析本身,也未涉及浮点、贝叶斯程序分析或 Agentic 程序分析,因此不落在核心研究问题上。引用 11 inbox
Nusrat Zahan, Philipp Burckhardt, Mikola Lysenko, Feross Aboukhadijeh, Laurie Williams
crossref: 2026-09-12

AI 速览

一句话:提出 SocketAI 工作流,用 GPT-3/4 检测 npm 恶意包,并结合静态分析预筛提升精度并降低成本。

现有恶意代码检测需集成多种工具,误分类率高。本文提出 SocketAI,一个基于大型语言模型的 npm 恶意代码审查工作流,并在包含 5,115 个 npm 包(其中 2,180 个含恶意代码)的基准上评估。研究将 GPT-3 与 GPT-4 同 CodeQL 静态分析(39 条定制规则)进行基线比较,并探讨静态分析作为预筛器与 SocketAI 结合时对分析文件数和成本的影响。结果显示,GPT-4 达到 99% 精确率和 97% F1,GPT-3 为 91% 精确率和 94% F1;相比静态分析,精确率和 F1 分别提升 16% 与 9%。预筛使需 LLM 分析的文件数减少 77.9%,GPT-3 成本降低 60.9%,GPT-4 降低 76.1%。定性分析发现数据窃取、任意代码执行和可疑域名是主要检测类别。

问题
现有 npm 恶意包检测依赖多工具组合,误分类率高,需要更自动化且高精度的方法。
方法
提出 SocketAI 审查工作流,利用 GPT-3/GPT-4 检测恶意代码;以 CodeQL 静态分析为基线,并评估静态分析预筛与 LLM 结合的流程。
评估
在 5,115 个 npm 包(2,180 个恶意)基准上比较精度、F1、分析文件数与成本,并进行定性分析。
原文摘要(Abstract)

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 SocketAI, we leverage a benchmark dataset of$5,115 \text{npm}$packages, of which 2,180 packages have malicious code. We conducted a baseline comparison of GPT3 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 packages 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. Prescreening files with a static analyzer reduces the number of files requiring LLM analysis by$\mathbf{7 7. 9 \%}$and decreases costs by$\mathbf{6 0. 9 \%}$for GPT-3 and$\mathbf{7 6. 1 \%}$for GPT-4. Our qualitative analysis identified data theft, execution of arbitrary code, and suspicious domain categories as the top detected malicious packages.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8909,
  title = {Leveraging Large Language Models to Detect NPM Malicious Packages},
  author = {Nusrat Zahan and Philipp Burckhardt and Mikola Lysenko and Feross Aboukhadijeh and Laurie Williams},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00146}
}