PYPILINE: Malicious PyPI Package Detection via Suspicious API Knowledge and Agent Workflow
About
Detecting malicious PyPI packages is crucial for maintaining the security of the open source software supply chain. Traditional static rule detection methods require continuous maintenance by experienced security personnel, resulting in high labor costs. Dynamic analysis methods require actual execution of the target package code, posing a risk of malicious code proliferation, and incurring significant runtime overhead and low detection efficiency. Machine learning and LLM methods iterate the detection kernel but cannot invoke multiple tools, resulting in insufficient automation.To address these issues, we propose a novel detection method called PYPILINE, which combines suspicious API knowledge and agent workflow. PYPILINE first performs static analysis on known malicious packages, extracting abstract syntax trees and generating API call graphs. From these graphs, a structured suspicious API knowledge base is extracted and constructed. In the agent workflow, PYPILINE uses RAG technology to invoke this knowledge base to enhance analytical capabilities, performing in-depth semantic analysis of the packages, outputting structured evaluation reports, and automatically sending the reports to a mail server.Experimental results show that PYPILINE achieves precision of 96.7\%, recall of 99.6\%, and F1 score of 98.1\%. F1 score is improved by 5.7 to 21.6 percentage points compared to baseline tools. When 30 threads execute concurrently, detecting a single package takes an average of only 0.6 seconds.Furthermore, we conducted a large scale empirical study of malware packages, systematically revealing common attack strategies and the most frequently abused APIs. PYPILINE provides an intelligent, efficient, and automated package detection solution, enhancing the security of the open source software ecosystem.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Malicious Package Detection | Malicious package evaluation dataset | Precision96.7 | 10 |