H[2]GLM: LLM-GNN Python Package Detection

Arxiv pdf 2026-07-01T00:00:00
arXiv Paper — PDF not available. Only the Executive Summary is available here. To read or download the full paper, visit the arXiv abstract page.

Abstract

Malicious Python packages have become a major threat to modern software supply chain ecosystems due to the widespread adoption of open-source repositories such as PyPI. Existing learning-based detection methods struggle to capture the hierarchical organization and heterogeneous interactions among different program entities. Although Large Language Models (LLMs) have demonstrated remarkable capabilities in code understanding and semantic reasoning, they are rarely integrated with structural program representations for finegrained malicious behavior analysis. In this paper, we propose an LLM-enhanced hierarchical heterogeneous graph representation learning framework for malicious Python package detection. The proposed framework constructs a hierarchical heterogeneous code graph that explicitly models heterogeneous code entities, together with different types of structural dependencies. To further enrich code representations, LLMs are leveraged to infer function-level semantic roles, introducing an additional layer of semantic heterogeneity. Based on this graph, we develop a hierarchical heterogeneous graph neural network that performs type-aware message passing over different node and edge categories, enabling effective modeling of malicious behavior propagation and accurate package-level classification. Furthermore, the proposed framework incorporates a function-level attribution mechanism which, combined with LLM reasoning, automatically identifies suspicious functions and localizes fine-grained malicious behaviors without requiring human expert intervention. Extensive experiments on real-world datasets demonstrate that the proposed framework consistently outperforms traditional machine learning methods, graph-based detectors, and state-ofthe-art LLMs across packages with varying sizes and dependency complexities, while providing accurate, robust, and interpretable malicious behavior localization. The replication package is available at: https://github.com/xxy33/malware

Loading executive summary...

LINK COPIED TO CLIPBOARD