arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.05259cs.SE
收藏

一种基于机器学习的恶意 PyPI 软件包检测方法

A Machine Learning-Based Approach For Detecting Malicious PyPI Packages

Haya Samaana, Diego Elias Costa, Emad Shihab, Ahmad Abdellatif

AI总结:

本文提出结合机器学习与静态分析的 PyPI 恶意软件包检测方法,通过检查元数据、代码、文件和文本特征,利用 stacking 集成分类器实现 0.94 的 F1-measure。

摘要:

背景。在现代软件开发中,外部库和软件包的使用日益普遍,这简化了软件开发流程,并使开发者能够用少量代码部署功能丰富的系统。尽管这种对代码复用的依赖带来了显著收益,但它也以恶意软件包的形式给已部署软件引入了严重风险,即伪装成有用库的有害且易受攻击的代码。目标。诸如 PyPI 之类的流行生态系统每周都会收到数千个新的软件包贡献,而区分安全贡献与有害贡献是一项重大挑战。迫切需要可靠的方法来检测并处理这些环境中存在的恶意软件包。方法。为应对这些挑战,我们提出一种数据驱动方法,该方法使用机器学习和静态分析来检查软件包的元数据、代码、文件和文本特征,以识别恶意软件包。结果。在 PyPI 生态系统内进行的评估中,我们使用 stacking 集成分类器识别恶意软件包,取得了 0.94 的 F1-measure。结论。该工具可以无缝集成到软件包审查流水线中,并且能够标记整个软件包,而不仅仅是恶意函数调用。这一增强强化了安全措施,并减少了开发者和注册表维护者的手动工作量,从而有助于维护生态系统的整体完整性。

英文摘要:

Background. In modern software development, the use of external libraries and packages is increasingly prevalent, streamlining the software development process and enabling developers to deploy feature-rich systems with little coding. While this reliance on reusing code offers substantial benefits, it also introduces serious risks for deployed software in the form of malicious packages - harmful and vulnerable code disguised as useful libraries. Aims. Popular ecosystems, such PyPI, receive thousands of new package contributions every week, and distinguishing safe contributions from harmful ones presents a significant challenge. There is a dire need for reliable methods to detect and address the presence of malicious packages in these environments. Method. To address these challenges, we propose a data-driven approach that uses machine learning and static analysis to examine the package's metadata, code, files, and textual characteristics to identify malicious packages. Results. In evaluations conducted within the PyPI ecosystem, we achieved an F1-measure of 0.94 for identifying malicious packages using a stacking ensemble classifier. Conclusions. This tool can be seamlessly integrated into package vetting pipelines and has the capability to flag entire packages, not just malicious function calls. This enhancement strengthens security measures and reduces the manual workload for developers and registry maintainers, thereby contributing to the overall integrity of the ecosystem.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑