MalGuard: Towards Real-Time, Accurate, and Actionable Detection of Malicious Packages in PyPI Ecosystem
Xingan Gao, Xiaobing Sun, Sicong Cao, Kaifeng Huang, Di Wu, Xiaolei Liu, Xingwei Lin, Yang Xiang
摘要
Malicious package detection has become a critical task in ensuring the security and stability of the PyPI. Existing detection approaches have focused on advancing model selection, evolving from traditional machine learning (ML) models to large language models (LLMs). However, as the complexity of the model increases, the time consumption also increases, which raises the question of whether a lightweight model achieves effective detection. Through empirical research, we demonstrate that collecting a sufficiently comprehensive feature set enables even traditional ML models to achieve outstanding performance. However, with the continuous emergence of new malicious packages, considerable human and material resources are required for feature analysis. Also, traditional ML model-based approaches lack of explainability to malicious packages.Therefore, we propose a novel approach MalGuard based on graph centrality analysis and the LIME (Local Interpretable Model-agnostic Explanations) algorithm to detect malicious packages.To overcome the above two challenges, we leverage graph centrality analysis to extract sensitive APIs automatically to replace manual analysis. To understand the sensitive APIs, we further refine the feature set using LLM and integrate the LIME algorithm with ML models to provide explanations for malicious packages. We evaluated MalGuard against six SOTA baselines with the same settings. Experimental results show that our proposed MalGuard, improves precision by 0.5%-33.2% and recall by 1.8%-22.1%. With MalGuard, we successfully identified 113 previously unknown malicious packages from a pool of 64,348 newly-uploaded packages over a five-week period, and 109 out of them have been removed by the PyPI official.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 6 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- An Empirical Study of Malicious Code In PyPI Ecosystem 引用了 LastPyMile: identifying the discrepancy between sources and packages
- PyFEX: Uncovering Evasive Python-based Threats via Resilient and Exhaustive Path Exploration 引用了 An Empirical Study of Malicious Code In PyPI Ecosystem
- PyFEX: Uncovering Evasive Python-based Threats via Resilient and Exhaustive Path Exploration 引用了 Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining Framework
- Bridging Expert Reasoning and LLM Detection: A Knowledge-Driven Framework for Malicious Packages 引用了 An Empirical Study of Malicious Code In PyPI Ecosystem
- Bridging Expert Reasoning and LLM Detection: A Knowledge-Driven Framework for Malicious Packages 引用了 Practical Automated Detection of Malicious npm Packages
- MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of Repositories 引用了 An Empirical Study of Malicious Code In PyPI Ecosystem
- MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of Repositories 引用了 Practical Automated Detection of Malicious npm Packages
- Coca: Improving and Explaining Graph Neural Network-Based Vulnerability Detection Systems 引用了 MVD: Memory-Related Vulnerability Detection Based on Flow-Sensitive Graph Neural Networks
- Practical Automated Detection of Malicious npm Packages 引用了 LastPyMile: identifying the discrepancy between sources and packages
- Well Begun is Half Done: Location-Aware and Trace-Guided Iterative Automated Vulnerability Repair 引用了 MVD: Memory-Related Vulnerability Detection Based on Flow-Sensitive Graph Neural Networks
- Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining Framework 引用了 An Empirical Study of Malicious Code In PyPI Ecosystem
- Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining Framework 引用了 LastPyMile: identifying the discrepancy between sources and packages
- Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining Framework 引用了 Practical Automated Detection of Malicious npm Packages
引用它的顶会 Paper6
- Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining FrameworkWenbo Guo, Chengwei Liu, Ming Kang, Yiran Zhang 等USENIX Security 2026 · 1 次引用
- PyFEX: Uncovering Evasive Python-based Threats via Resilient and Exhaustive Path ExplorationMeng Wang, Yue Ma, Majid Garoosi, Wenting Fan 等CCS 2026
- Bridging Expert Reasoning and LLM Detection: A Knowledge-Driven Framework for Malicious PackagesWenbo Guo, Shiwen Song, Jiaxun Guo, Zhengzi Xu 等WWW 2026
- MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of RepositoriesJian Zhao, Shenao Wang, Qingyang Wu, Yanjie Zhao 等ISSTA 2026
- Well Begun is Half Done: Location-Aware and Trace-Guided Iterative Automated Vulnerability RepairZhenlei Ye, Xiaobing Sun, Sicong Cao, Lili Bo 等ICSE 2026
它引用的 Paper12
- MVD: Memory-Related Vulnerability Detection Based on Flow-Sensitive Graph Neural NetworksSicong Cao, Xiaobing Sun, Lili Bo, Rongxin Wu 等ICSE 2022 · 100 次引用
- Practical Automated Detection of Malicious npm PackagesAdriana Sejfia, Max SchäferICSE 2022 · 65 次引用
- LastPyMile: identifying the discrepancy between sources and packagesDuc-Ly Vu, Fabio Massacci, Ivan Pashchenko, Henrik Plate 等FSE 2021 · 53 次引用
- An Empirical Study of Malicious Code In PyPI EcosystemWenbo Guo, Zhengzi Xu, Chengwei Liu, Cheng Huang 等ASE 2023 · 31 次引用
- Coca: Improving and Explaining Graph Neural Network-Based Vulnerability Detection SystemsSicong Cao, Xiaobing Sun, Xiaoxue Wu, David Lo 等ICSE 2024 · 27 次引用
相关 Paper
- Maltracker: A Fine-Grained NPM Malware Tracker Copiloted by LLM-Enhanced DatasetZeliang Yu, Ming Wen, Xiaochen Guo, Hai JinISSTA 2024 · 16 次引用
- A Needle is an Outlier in a Haystack: Hunting Malicious PyPI Packages with Code ClusteringWentao Liang, Xiang Ling, Jingzheng Wu, Tianyue Luo 等ASE 2023 · 15 次引用
- Efficient Code Analysis via Graph Representation Learning-Guided Large Language ModelsHang Gao, Tao Peng, Baoquan Cui, Hong Huang 等ICML 2026 · 1 次引用
- PyExplainer: Explaining the Predictions of Just-In-Time Defect ModelsChanathip Pornprasit, Chakkrit Tantithamthavorn, Jirayus Jiarpakdee, Michael Fu 等ASE 2021 · 52 次引用
- Explainable and Fine-Grained Safeguarding of LLM Multi-Agent Systems via Bi-Level Graph Anomaly DetectionJunjun Pan, Yixin Liu, Rui Miao, Kaize Ding 等ACL 2026 · 6 次引用
