Work

Decoding Maliciousness: LLM-Assisted Semantic Filtering for Scalable Malicious PyPI Package Detection

Year: 2026
Type: article
Abstract: Context: The Python Package Index (PyPI) has become a primary target for software supply chain attacks. Existing detection methods often rely on single-dimensional analysis, which struggles to meet the scalability and real-time requirements of modern software ecosystems.Objectives: This study aims to develop a scalable and automated framework to accurately identify malicious PyPI packages by fusing multi-dimensional features, specifically focusing on the integration of code structural patterns and deep semantic understanding.Methods: We propose a framework that first employs static analysis to construct API call graphs and calculate four graph centrality metrics to capture structural features. Subsequently, Large Language Models (LLMs) with specialized prompt engineering are introduced to screen high-centrality APIs and eliminate noise. Finally, optimized structural features are fused with metadata features to construct a robust classification model.Results: Evaluations on a large-scale dataset of over 20,000 samples demonstrate that the proposed method achieves 97.2% precision and 97.3% F1-score. Notably, the framework exhibits exceptional efficiency, with an average end-to-end detection time of less than 1 second per package. It also shows strong robustness in highly imbalanced (1:50) scenarios.Conclusion: Our approach offers a high-precision, scalable solution for securing the open-source software supply chain. By effectively combining graph-based structural analysis with LLM-powered semantics, it provides a practical tool for advancing software quality assurance in real-world environments.
Source: Electronics
Language: English
Open Access status: gold
Estimated APC paid: $2,896
OpenAlex ID: W7160388424
FWCI:
Cites: 19
Cited by:
Related to: 10