USENIX Security2025Top-tier venue
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
Abstract
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.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
6 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- An Empirical Study of Malicious Code In PyPI Ecosystem cites LastPyMile: identifying the discrepancy between sources and packages
- PyFEX: Uncovering Evasive Python-based Threats via Resilient and Exhaustive Path Exploration cites An Empirical Study of Malicious Code In PyPI Ecosystem
- PyFEX: Uncovering Evasive Python-based Threats via Resilient and Exhaustive Path Exploration cites 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 cites An Empirical Study of Malicious Code In PyPI Ecosystem
- Bridging Expert Reasoning and LLM Detection: A Knowledge-Driven Framework for Malicious Packages cites Practical Automated Detection of Malicious npm Packages
- MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of Repositories cites An Empirical Study of Malicious Code In PyPI Ecosystem
- MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of Repositories cites Practical Automated Detection of Malicious npm Packages
- Coca: Improving and Explaining Graph Neural Network-Based Vulnerability Detection Systems cites MVD: Memory-Related Vulnerability Detection Based on Flow-Sensitive Graph Neural Networks
- Practical Automated Detection of Malicious npm Packages cites LastPyMile: identifying the discrepancy between sources and packages
- Well Begun is Half Done: Location-Aware and Trace-Guided Iterative Automated Vulnerability Repair cites 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 cites An Empirical Study of Malicious Code In PyPI Ecosystem
- Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining Framework cites LastPyMile: identifying the discrepancy between sources and packages
- Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining Framework cites Practical Automated Detection of Malicious npm Packages
Cited by top-tier papers6
- Cutting the Gordian Knot: Detecting Malicious PyPI Packages via a Knowledge-Mining FrameworkWenbo Guo, Chengwei Liu, Ming Kang, Yiran Zhang et al.USENIX Security 2026 · 1 citation
- PyFEX: Uncovering Evasive Python-based Threats via Resilient and Exhaustive Path ExplorationMeng Wang, Yue Ma, Majid Garoosi, Wenting Fan et al.CCS 2026
- Bridging Expert Reasoning and LLM Detection: A Knowledge-Driven Framework for Malicious PackagesWenbo Guo, Shiwen Song, Jiaxun Guo, Zhengzi Xu et al.WWW 2026
- MalTotal: Cost-Effective and Language-Agnostic Malicious Code Poisoning Detection for Millions of RepositoriesJian Zhao, Shenao Wang, Qingyang Wu, Yanjie Zhao et al.ISSTA 2026
- Well Begun is Half Done: Location-Aware and Trace-Guided Iterative Automated Vulnerability RepairZhenlei Ye, Xiaobing Sun, Sicong Cao, Lili Bo et al.ICSE 2026
Builds on12
- MVD: Memory-Related Vulnerability Detection Based on Flow-Sensitive Graph Neural NetworksSicong Cao, Xiaobing Sun, Lili Bo, Rongxin Wu et al.ICSE 2022 · 100 citations
- Practical Automated Detection of Malicious npm PackagesAdriana Sejfia, Max SchäferICSE 2022 · 65 citations
- LastPyMile: identifying the discrepancy between sources and packagesDuc-Ly Vu, Fabio Massacci, Ivan Pashchenko, Henrik Plate et al.FSE 2021 · 53 citations
- An Empirical Study of Malicious Code In PyPI EcosystemWenbo Guo, Zhengzi Xu, Chengwei Liu, Cheng Huang et al.ASE 2023 · 31 citations
- Coca: Improving and Explaining Graph Neural Network-Based Vulnerability Detection SystemsSicong Cao, Xiaobing Sun, Xiaoxue Wu, David Lo et al.ICSE 2024 · 27 citations
Related papers
- Maltracker: A Fine-Grained NPM Malware Tracker Copiloted by LLM-Enhanced DatasetZeliang Yu, Ming Wen, Xiaochen Guo, Hai JinISSTA 2024 · 16 citations
- A Needle is an Outlier in a Haystack: Hunting Malicious PyPI Packages with Code ClusteringWentao Liang, Xiang Ling, Jingzheng Wu, Tianyue Luo et al.ASE 2023 · 15 citations
- Efficient Code Analysis via Graph Representation Learning-Guided Large Language ModelsHang Gao, Tao Peng, Baoquan Cui, Hong Huang et al.ICML 2026 · 1 citation
- PyExplainer: Explaining the Predictions of Just-In-Time Defect ModelsChanathip Pornprasit, Chakkrit Tantithamthavorn, Jirayus Jiarpakdee, Michael Fu et al.ASE 2021 · 52 citations
- Explainable and Fine-Grained Safeguarding of LLM Multi-Agent Systems via Bi-Level Graph Anomaly DetectionJunjun Pan, Yixin Liu, Rui Miao, Kaize Ding et al.ACL 2026 · 6 citations
