arXiv:2512.04338cs.CRcs.LG2025-12被引 1

打造可通用的恶意Python包检测器,兼顾抗混淆与灵活配置。

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

  • 用细粒度代码混淆生成对抗样本,结合对抗训练提升鲁棒性2.5倍。
  • 在PyPI和企业场景中分别实现0.1%和10%的误报率,每日发现超2个恶意包。
  • 适配公共仓库与企业部署,仅需几分钟即可人工复核误报。

供应链攻击通过恶意Python包日益增多,亟需稳健检测方案。现有方法忽视两大挑战:对代码混淆等对抗性变换的鲁棒性不足,以及难以适应不同角色对误报率(FPR)的不同需求——如PyPI维护者需低至0.1%的FPR,企业安全团队可容忍10%。本文提出一种鲁棒且可适配的检测器,支持无缝集成于PyPI及企业环境。为增强鲁棒性,设计细粒度代码混淆生成对抗包,并结合对抗训练(AT),使检测器抗混淆能力提升2.5倍。在80天内从PyPI收集的122,398个包上评估显示,AT能多发现10%的混淆恶意包,但轻微降低非混淆样本表现。通过两个案例验证:一为PyPI维护者(0.1% FPR),分析37天内91,949个包,日均检出2.48个恶意包,仅2.18个误报;二为企业团队(10% FPR),分析某跨国公司采纳的1,596个包,日均误报仅1.24个。整体共发现346个恶意包并提交社区。检测耗时仅数分钟,适合快速人工审查。

原文摘要 · Abstract (English)

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.

恶意包检测对抗训练供应链安全Python生态

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。