arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.04338cs.CRcs.LG
收藏

一个检测器适用于所有:从PyPI到企业的恶意包鲁棒且自适应检测

One Detector Fits All: Robust and Adaptive Detection of Malicious Packages from PyPI to Enterprises

Endor Labs(Endor实验室)

Biagio Montaruli, Luca Compagna, Serena Elisa Ponta, Davide Balzarotti

AI总结:

本文提出一种鲁棒且自适应的恶意包检测器,适用于PyPI和企业环境,通过对抗性训练提升检测鲁棒性,并在不同FPR需求下实现高效检测。

摘要:

随着通过恶意Python包进行供应链攻击的兴起,迫切需要稳健的检测解决方案。然而,当前的方法却忽视了两个关键挑战:对对抗性源代码变换的鲁棒性和对不同行为者不同假阳性率(FPR)要求的适应性,从仓库维护人员(要求低FPR)到企业安全团队(更高的FPR容忍度)。我们介绍了一个能够无缝集成到公共仓库如PyPI和企业生态系统中的稳健检测器。为确保鲁棒性,我们提出了一种新的方法来生成对抗性包,使用细粒度的代码混淆。将这些与对抗性训练(AT)结合,通过2.5倍增强检测器的鲁棒性。我们通过测试我们的检测器在PyPI上每天收集的122,398个包上,全面评估AT的有效性,显示AT需要仔细应用:它使检测器对混淆更加鲁棒,并允许发现10%更多的混淆包,但略微降低非混淆包的性能。我们通过两个案例研究展示了检测器的生产适应性:(i)一个用于PyPI维护人员(调整为0.1% FPR)和(ii)一个用于企业团队(调整为10% FPR)。在前者中,我们分析了37天内从PyPI收集的91,949个包,实现了每天2.48个恶意包的检测率,仅2.18个假阳性。在后者中,我们分析了被跨国软件公司采用的1,596个包,仅获得1.24个假阳性。这些结果表明,我们的检测器可以无缝集成到公共仓库如PyPI和企业生态系统中,确保极低的时间预算,只需几分钟来审查假阳性。总体而言,我们发现了346个恶意包,现已报告给社区。

英文摘要:

The rise of supply chain attacks via malicious Python packages demands robust detection solutions. Current approaches, however, overlook two critical challenges: robustness against adversarial source code transformations and adaptability to the varying false positive rate (FPR) requirements of different actors, from repository maintainers (requiring low FPR) to enterprise security teams (higher FPR tolerance). We introduce a robust detector capable of seamless integration into both public repositories like PyPI and enterprise ecosystems. To ensure robustness, we propose a novel methodology for generating adversarial packages using fine-grained code obfuscation. Combining these with adversarial training (AT) enhances detector robustness by 2.5x. We comprehensively evaluate AT effectiveness by testing our detector against 122,398 packages collected daily from PyPI over 80 days, showing that AT needs careful application: it makes the detector more robust to obfuscations and allows finding 10% more obfuscated packages, but slightly decreases performance on non-obfuscated packages. We demonstrate production adaptability of our detector via two case studies: (i) one for PyPI maintainers (tuned at 0.1% FPR) and (ii) one for enterprise teams (tuned at 10% FPR). In the former, we analyze 91,949 packages collected from PyPI over 37 days, achieving a daily detection rate of 2.48 malicious packages with only 2.18 false positives. In the latter, we analyze 1,596 packages adopted by a multinational software company, obtaining only 1.24 false positives daily. These results show that our detector can be seamlessly integrated into both public repositories like PyPI and enterprise ecosystems, ensuring a very low time budget of a few minutes to review the false positives. Overall, we uncovered 346 malicious packages, now reported to the community.

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

↑