解开 Gordian 节:通过知识挖掘框架检测恶意 PyPI 包
Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining Framework
AI总结:
PyGuard 通过知识挖掘框架提升 PyPI 恶意包检测准确率,实现 99.50% 准确率,识别 219 个新恶意包,展示语义理解在跨编程语言中的应用价值。
摘要:
Python 包索引(PyPI)已成为恶意行为者的目标,但现有检测工具的误报率高达 15-30%,错误地将三分之一的合法包标记为恶意。这一问题的根源在于当前工具依赖于简单的语法规则而非语义理解,无法区分相同 API 调用在合法与恶意用途中的区别。为解决这一挑战,我们提出 PyGuard,一个知识驱动的框架,通过从现有工具的误报和误判中提取模式,将检测失败转化为有用的行为主知。我们的方法利用分层模式挖掘来识别区分恶意与良性代码的行为序列,利用大型语言模型创建超越语法变化的语义抽象,并将此知识整合到一个检测系统中,该系统结合了精确模式匹配与上下文推理。PyGuard 实现了 99.50% 的准确率,仅 2 个误报,而现有工具有 1,927-2,117 个误报,保持 98.28% 的准确率在混淆代码上,并在现实部署中识别了 219 个之前未知的恶意包。行为模式在跨生态系统中显示出 98.07% 的准确性,证明了语义理解能够实现跨编程语言的知识迁移。
英文摘要:
The Python Package Index (PyPI) has become a target for malicious actors, yet existing detection tools generate false positive rates of 15-30%, incorrectly flagging one-third of legitimate packages as malicious. This problem arises because current tools rely on simple syntactic rules rather than semantic understanding, failing to distinguish between identical API calls serving legitimate versus malicious purposes. To address this challenge, we propose PyGuard, a knowledge-driven framework that converts detection failures into useful behavioral knowledge by extracting patterns from existing tools' false positives and negatives. Our method utilizes hierarchical pattern mining to identify behavioral sequences that distinguish malicious from benign code, employs Large Language Models to create semantic abstractions beyond syntactic variations, and combines this knowledge into a detection system that integrates exact pattern matching with contextual reasoning. PyGuard achieves 99.50% accuracy with only 2 false positives versus 1,927-2,117 in existing tools, maintains 98.28% accuracy on obfuscated code, and identified 219 previously unknown malicious packages in real-world deployment. The behavioral patterns show cross-ecosystem applicability with 98.07% accuracy on NPM packages, demonstrating that semantic understanding enables knowledge transfer across programming languages.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。