paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Needle is an Outlier in a Haystack: Hunting Malicious PyPI Packages with Code Clustering

针是干草堆中的离群点:通过代码聚类猎捕恶意 PyPI 包
ASE 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)2023匹配度 2/10 · 论文属于软件供应链安全方向,使用代码聚类检测恶意 PyPI 安装脚本,与用户关注的 PL/AI 交叉(静态分析、LLM/Agent、浮点程序分析、贝叶斯程序分析)没有直接关联。虽涉及代码分析,但方法核心是无监督聚类异常检测,并非用户研究画像中的核心问题。引用 36 inbox
Wentao Liang, Xiang Ling, Jingzheng Wu, Tianyue Luo, Yanjun Wu
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 MPHunter,用代码聚类无先验地检测 PyPI 恶意安装脚本,两月发现 60 个新恶意包。

PyPI 的开源特性使其面临恶意包安全风险,已有检测方法依赖难以获取的显式知识(如污点源汇与恶意代码模式),易漏检新恶意包。本文提出轻量有效的 MPHunter,无需显式先验知识。它基于两个观察:恶意包远少于良性包;恶意包安装脚本的功能与良性包差异显著,后者常形成聚类。MPHunter 对安装脚本聚类并识别离群点,再按离群程度及与已知恶意实例的距离排序,突出潜在恶意包。在两个月的 31,329 个新上传包中,MPHunter 发现 60 个此前未知的恶意包,均获 PyPI 官方确认;人工分析表明其识别所有潜在恶意安装脚本的召回率为 100%。

问题
PyPI 上恶意包泛滥,但现有检测依赖污点源汇、恶意模式等难以获取的显式知识,导致对新兴恶意包漏检严重。
方法
MPHunter 无先验地聚类 PyPI 包的安装脚本,识别离群点,并按离群程度及与已知恶意样本的距离排序以突出可疑包。
评估
在两个月 31,329 个新上传包中检测出 60 个官方确认的未知恶意包;人工分析显示对潜在恶意安装脚本召回率达 100%。
原文摘要(Abstract)

As the most popular Python software repository, PyPI has become an indispensable part of the Python ecosystem. Regrettably, the open nature of PyPI exposes end-users to substantial security risks stemming from malicious packages. Consequently, the timely and effective identification of malware within the vast number of newly-uploaded PyPI packages has emerged as a pressing concern. Existing detection methods are dependent on difficult-to-obtain explicit knowledge, such as taint sources, sinks, and malicious code patterns, rendering them susceptible to overlooking emergent malicious packages. In this paper, we present a lightweight and effective method, namely MPHunter, to detect malicious packages without requiring any explicit prior knowledge. MPHunter is founded upon two fundamental and insightful observations. First, malicious packages are considerably rarer than benign ones, and second, the functionality of installation scripts for malicious packages diverges significantly from those of benign packages, with the latter frequently forming clusters. Consequently, MPHunter utilizes clustering techniques to group the installation scripts of PyPI packages and identifies outliers. Subsequently, MPHunter ranks the outliers according to their outlierness and the distance between them and known malicious instances, thereby effectively highlighting potential evil packages. With MPHunter, we successfully identified 60 previously unknown malicious packages from a pool of 31,329 newly-uploaded packages over a two-month period. All of them have been confirmed by the PyPI official. Moreover, a manual analysis shows that MPHunter recognizes all potentially malicious installation scripts with a recall of 100% across all analyzed packages. We assert that MPHunter offers a valuable and advantageous supplement to existing detection techniques, augmenting the arsenal of software supply chain security analysis.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{LiangLWLW23,
  title = {A Needle is an Outlier in a Haystack: Hunting Malicious PyPI Packages with Code Clustering},
  author = {Wentao Liang and Xiang Ling and Jingzheng Wu and Tianyue Luo and Yanjun Wu},
  booktitle = {ASE},
  year = {2023},
  doi = {10.1109/ase56229.2023.00085}
}