LLM-SGCF: A Robust Malware Detection Framework with Spatially Guided Convolution
Abstract
1. Introduction
- We propose an LLM-based semantic completion strategy for API behaviors. By generating interpretable behavioral descriptions and encoding them into vector representations, this approach translates sparse symbolic API sequences into rich contextual semantic features, thereby substantially enhancing the model’s robustness against code obfuscation and variants at the input level.
- We design a novel Spatially Guided Convolution (SGC) module to extract complex structural dependencies. By projecting sequence semantics into a two-dimensional feature space, this module leverages attention guidance to localize critical malicious segments and employs convolutional modeling to capture cross-position dependencies, effectively strengthening the representation of key call intervals.
- We comprehensively validate the proposed framework through extensive experiments on multiple benchmark datasets. Empirical results demonstrate that our method achieves peak accuracy rates of 84.88%, 95.82%, and 63.15% on the Aliyun multi-class, Aliyun binary, and Catak multi-class tasks, respectively, substantially outperforming state-of-the-art baselines and exhibiting superior robustness.
2. Related Work
2.1. Traditional Malicious Code Detection Methods
2.2. Deep Learning-Based Malicious Code Detection Methods
2.3. Semantic Enhancement Detection Methods Based on Large Language Models
3. Method
3.1. API Call Sequence Preprocessing
3.2. Semantic Enhancement Driven by Large Language Models
3.3. Spatially Guided Convolution Module
| Algorithm 1: Spatially Guided Convolution (SGC) forward propagation |
|
3.4. Multi-Scale Convolution Fusion and Classification
4. Experiments
4.1. Dataset Description
4.2. Baselines
4.3. Evaluation Metrics
4.4. Parameter Setting
4.5. Quantitative Results
4.6. Model Convergence Stability Analysis
4.7. Classification Performance Visualization
4.8. Sensitivity Analysis
4.8.1. Sensitivity Analysis of Sequence Length
4.8.2. Parameter Sensitivity Analysis
4.9. Ablation Experiment
4.9.1. Effectiveness of the Spatially Guided Convolution Module
4.9.2. Impact of Multi-Scale Convolution Kernel Combinations
4.10. Discussion on Computational Complexity
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Cui, Z.; Zhao, Y.; Cao, Y.; Cai, X.; Zhang, W.; Chen, J. Malicious code detection under 5G HetNets based on a multi-objective RBM model. IEEE Netw. 2021, 35, 82–87. [Google Scholar] [CrossRef]
- Kim, J.Y.; Cho, S.B. Obfuscated malware detection using deep generative model based on global/local features. Comput. Secur. 2022, 112, 102501. [Google Scholar] [CrossRef]
- Yan, K.; Zhang, Y.; Tang, H.; Ren, C.; Zhang, J.; Wang, G.; Wang, H. Signature detection, restoration, and verification: A novel chinese document signature forgery detection benchmark. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, New Orleans, LA, USA, 19–20 June 2022; pp. 5163–5172. [Google Scholar]
- Wang, K.; Jiang, Q.; Wu, Y.; Wang, B.; Zhang, H. STATGRAPH: Effective in-Vehicle Intrusion Detection via Multi-View Statistical Graph Learning. IEEE Trans. Mob. Comput. 2025, 25, 6335–6351. [Google Scholar] [CrossRef]
- Wang, Z.; Wang, W.; Yang, Y.; Han, Z.; Xu, D.; Su, C. CNN-and GAN-based classification of malicious code families: A code visualization approach. Int. J. Intell. Syst. 2022, 37, 12472–12489. [Google Scholar] [CrossRef]
- Guan, Z.; Wang, J.; Wang, X.; Xin, W.; Cui, J.; Jing, X. A comparative study of RNN-based methods for web malicious code detection. In Proceedings of the 2021 IEEE 6th International Conference on Computer and Communication Systems (ICCCS), Chengdu, China, 23–26 April 2021; pp. 769–773. [Google Scholar]
- Alshomrani, M.; Albeshri, A.; Alturki, B.; Alallah, F.S.; Alsulami, A.A. Survey of Transformer-Based Malicious Software Detection Systems. Electronics 2024, 13, 4677. [Google Scholar] [CrossRef]
- Yang, H.; Wang, Y.; Zhang, L.; Cheng, X.; Hu, Z. A novel Android malware detection method with API semantics extraction. Comput. Secur. 2024, 137, 103651. [Google Scholar] [CrossRef]
- Kamalloo, E.; Zhang, X.; Ogundepo, O.; Thakur, N.; Alfonso-Hermelo, D.; Rezagholizadeh, M.; Lin, J. Evaluating embedding APIs for information retrieval. arXiv 2023, arXiv:2305.06300. [Google Scholar] [CrossRef]
- Chen, T.; Zeng, H.; Lv, M.; Zhu, T. CTIMD: Cyber threat intelligence enhanced malware detection using API call sequences with parameters. Comput. Secur. 2024, 136, 103518. [Google Scholar] [CrossRef]
- Kouliaridis, V.; Karopoulos, G.; Kambourakis, G. Assessing the effectiveness of llms in android application vulnerability analysis. In Proceedings of the International Conference on Attacks and Defenses for Internet-of-Things, Hangzhou, China, 13–14 December 2024; pp. 139–154. [Google Scholar]
- Cheng, Y.; Shar, L.K.; Zhang, T.; Yang, S.; Dong, C.; Lo, D.; Lv, S.; Shi, Z.; Sun, L. Llm-enhanced static analysis for precise identification of vulnerable oss versions. arXiv 2024, arXiv:2408.07321. [Google Scholar]
- Nam, D.; Macvean, A.; Hellendoorn, V.; Vasilescu, B.; Myers, B. Using an llm to help with code understanding. In Proceedings of the IEEE/ACM 46th International Conference on Software Engineering, Lisbon, Portugal, 14–20 April 2024; pp. 1–13. [Google Scholar]
- Hoseini, S.; Burgdorf, A.; Paulus, A.; Meisen, T.; Quix, C.; Pomp, A. Challenges and Opportunities of LLM-Augmented Semantic Model Creation for Dataspaces. In Proceedings of the European Semantic Web Conference, Hersonissos, Greece, 26–30 May 2024; pp. 183–200. [Google Scholar]
- Cloud, A. Alibaba Cloud Malware Detection Based on Behaviors. 2018. Available online: https://tianchi.aliyun.com/getStart/information.htm?raceId=231694 (accessed on 11 November 2018).
- Catak, F.O.; Yazı, A.F.; Elezaj, O.; Ahmed, J. Deep learning based Sequential model for malware analysis using Windows exe API Calls. PeerJ Comput. Sci. 2020, 6, e285. [Google Scholar] [CrossRef]
- Sun, L.; Wang, Y.; Ren, Y.; Xia, F. Path signature-based xai-enabled network time series classification. Sci. China Inf. Sci. 2024, 67, 170305. [Google Scholar] [CrossRef]
- Mourtaji, Y.; Bouhorma, M.; Alghazzawi, D.; Aldabbagh, G.; Alghamdi, A. Hybrid Rule-Based Solution for Phishing URL Detection Using Convolutional Neural Network. Wirel. Commun. Mob. Comput. 2021, 2021, 8241104. [Google Scholar] [CrossRef]
- Kouli, M.; Rasoolzadegan, A. A feature-based method for detecting design patterns in source code. Symmetry 2022, 14, 1491. [Google Scholar] [CrossRef]
- Bhadra, T.; Mallik, S.; Hasan, N.; Zhao, Z. Comparison of five supervised feature selection algorithms leading to top features and gene signatures from multi-omics data in cancer. BMC Bioinform. 2022, 23, 153. [Google Scholar] [CrossRef]
- Rabbani, M.; Wang, Y.; Khoshkangini, R.; Jelodar, H.; Zhao, R.; Bagheri Baba Ahmadi, S.; Ayobi, S. A review on machine learning approaches for network malicious behavior detection in emerging technologies. Entropy 2021, 23, 529. [Google Scholar] [CrossRef]
- Yan, A.; Chen, Z.; Zhang, H.; Peng, L.; Yan, Q.; Hassan, M.U.; Zhao, C.; Yang, B. Effective detection of mobile malware behavior based on explainable deep neural network. Neurocomputing 2021, 453, 482–492. [Google Scholar] [CrossRef]
- Gonzalez, D.; Zimmermann, T.; Godefroid, P.; Schäfer, M. Anomalicious: Automated detection of anomalous and potentially malicious commits on github. In Proceedings of the 2021 IEEE/ACM 43rd International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), Madrid, Spain, 25–28 May 2021; pp. 258–267. [Google Scholar]
- Hong, Y.; Li, Q.; Yang, Y.; Shen, M. Graph based encrypted malicious traffic detection with hybrid analysis of multi-view features. Inf. Sci. 2023, 644, 119229. [Google Scholar] [CrossRef]
- Chen, Z.; Xu, J.; Peng, T.; Yang, C. Graph convolutional network-based method for fault diagnosis using a hybrid of measurement and prior knowledge. IEEE Trans. Cybern. 2021, 52, 9157–9169. [Google Scholar] [CrossRef] [PubMed]
- Liu, R.; Wang, Y.; Guo, Z.; Xu, H.; Qin, Z.; Ma, W.; Zhang, F. TransURL: Improving malicious URL detection with multi-layer Transformer encoding and multi-scale pyramid features. Comput. Netw. 2024, 253, 110707. [Google Scholar] [CrossRef]
- Wang, Y.; Shi, Y.; Yang, T.; Wang, W.; Sun, Z.; Zhang, Y. Structural performance warning based on computer intelligent monitoring and fractional-order multi-rate Kalman fusion method. Fractal Fract. 2026, 10, 186. [Google Scholar] [CrossRef]
- Chen, X.; Li, C.; Wang, D.; Wen, S.; Zhang, J.; Nepal, S.; Xiang, Y.; Ren, K. Android HIV: A study of repackaging malware for evading machine-learning detection. IEEE Trans. Inf. Forensics Secur. 2019, 15, 987–1001. [Google Scholar] [CrossRef]
- Hossain, A.A.; PK, M.K.; Zhang, J.; Amsaad, F. Malicious code detection using llm. In Proceedings of the NAECON 2024—IEEE National Aerospace and Electronics Conference, Fairborn, OH, USA, 15–18 July 2024; pp. 414–416. [Google Scholar]
- Deng, Z.; Ma, W.; Han, Q.; Zhou, W.; Zhu, X.; Wen, S.; Xiang, Y. Exploring DeepSeek: A Survey on Advances, Applications, Challenges and Future Directions. IEEE/CAA J. Autom. Sin. 2025, 12, 872–893. [Google Scholar] [CrossRef]
- Lu, G.; Ju, X.; Chen, X.; Pei, W.; Cai, Z. GRACE: Empowering LLM-based software vulnerability detection with graph structure and in-context learning. J. Syst. Softw. 2024, 212, 112031. [Google Scholar] [CrossRef]
- Zhu, X.; Zhou, W.; Han, Q.L.; Ma, W.; Wen, S.; Xiang, Y. When Software Security Meets Large Language Models: A Survey. IEEE/CAA J. Autom. Sin. 2025, 12, 317–334. [Google Scholar] [CrossRef]
- Cheng, W.; Sun, K.; Zhang, X.; Wang, W. Security attacks on llm-based code completion tools. In Proceedings of the AAAI Conference on Artificial Intelligence, Philadelphia, PA, USA, 25 February–4 March 2025; pp. 23669–23677. [Google Scholar]
- Zhong, A.; Mo, D.; Liu, G.; Liu, J.; Lu, Q.; Zhou, Q.; Wu, J.; Li, Q.; Wen, Q. Logparser-llm: Advancing efficient log parsing with large language models. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, Barcelona, Spain, 25–29 August 2024; pp. 4559–4570. [Google Scholar]
- Zhou, W.; Zhu, X.; Han, Q.L.; Li, L.; Chen, X.; Wen, S.; Xiang, Y. The Security of Using Large Language Models—A Survey with Emphasis on ChatGPT. IEEE/CAA J. Autom. Sin. 2025, 12, 1–26. [Google Scholar] [CrossRef]
- Zhan, X.; Carrillo, J.C.; Seymour, W.; Such, J. Malicious LLM-Based Conversational AI Makes Users Reveal Personal Information. arXiv 2025, arXiv:2506.11680. [Google Scholar] [CrossRef]
- Chen, J.; Zhong, Q.; Wang, Y.; Ning, K.; Liu, Y.; Xu, Z.; Zhao, Z.; Chen, T.; Zheng, Z. Rmcbench: Benchmarking large language models’ resistance to malicious code. In Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering, Sacramento, CA, USA, 27 October–1 November 2024; pp. 995–1006. [Google Scholar]
- Deng, Z.; Sun, R.; Xue, M.; Ma, W.; Wen, S.; Nepal, S.; Yang, X. Hardening LLM Fine-Tuning: From Differentially Private Data Selection to Trustworthy Model Quantization. IEEE Trans. Inf. Forensics Secur. 2025, 20, 7211–7226. [Google Scholar] [CrossRef]
- Dang, D.; Di Troia, F.; Stamp, M. Malware classification using long short-term memory models. arXiv 2021, arXiv:2103.02746. [Google Scholar] [CrossRef]
- Yuan, L.; Zeng, Z.; Lu, Y.; Ou, X.; Feng, T. A character-level BiGRU-attention for phishing classification. In Proceedings of the International Conference on Information and Communications Security, Beijing, China, 15–17 December 2019; pp. 746–762. [Google Scholar]
- Zhang, Z.; Qi, P.; Wang, W. Dynamic malware analysis with feature engineering and feature learning. In Proceedings of the AAAI Conference on Artificial Intelligence, New York, NY, USA, 7–12 February 2020; pp. 1210–1217. [Google Scholar]
- Qin, B.; Wang, Y.; Ma, C. API call based ransomware dynamic detection approach using textCNN. In Proceedings of the 2020 International Conference on Big Data, Artificial Intelligence and Internet of Things Engineering (ICBAIE), Virtual, 12–14 June 2020; pp. 162–166. [Google Scholar]
- Kolosnjaji, B.; Zarras, A.; Webster, G.; Eckert, C. Deep learning for classification of malware system call sequences. In Proceedings of the Australasian Joint Conference on Artificial Intelligence, Hobart, Australia, 30 November–4 December 2016; pp. 137–149. [Google Scholar]
- Li, C.; Lv, Q.; Li, N.; Wang, Y.; Sun, D.; Qiao, Y. A novel deep framework for dynamic malware detection based on API sequence intrinsic features. Comput. Secur. 2022, 116, 102686. [Google Scholar] [CrossRef]
- Zhang, S.; Wu, J.; Zhang, M.; Yang, W. Dynamic malware analysis based on API sequence semantic fusion. Appl. Sci. 2023, 13, 6526. [Google Scholar] [CrossRef]
- Demirkıran, F.; Çayır, A.; Ünal, U.; Dağ, H. An ensemble of pre-trained transformer models for imbalanced multiclass malware classification. Comput. Secur. 2022, 121, 102846. [Google Scholar] [CrossRef]
- Trizna, D.; Demetrio, L.; Biggio, B.; Roli, F. Nebula: Self-attention for dynamic malware analysis. IEEE Trans. Inf. Forensics Secur. 2024, 19, 6155–6167. [Google Scholar] [CrossRef]
- Xu, Z.; Fang, X.; Yang, G. Malbert: A novel pre-training method for malware detection. Comput. Secur. 2021, 111, 102458. [Google Scholar] [CrossRef]









| Parameter Name | Value |
|---|---|
| Epochs | 100 |
| Training/Validation Batch Size | 8 |
| Test Batch Size | 12 |
| Learning Rate | 0.001 |
| Random Seed | 42 |
| Optimizer Type | Adam |
| Weight Decay | |
| Loss Function | Cross-Entropy Loss |
| Learning Rate Scheduler | StepLR (Step = 20, ) |
| Embedding Dimension | 768 |
| Dropout Rate | 0.3 |
| Maximum API Sequence Length | 100 |
| Explanation Text Word Limit | 300 |
| Method | Source | Type | Aliyun (Multi-ACC) | Aliyun (Binary-ACC) | Catak (Multi-ACC) |
|---|---|---|---|---|---|
| Kolosnjaji [43] | SIP’16 | CNN+RNN-based | 81.57% | 93.38% | 45.15% |
| BiGRU [40] | ICICS’19 | RNN-based | 81.43% | 93.52% | 49.65% |
| TextCNN [42] | ICBAIE’20 | CNN-based | 83.44% | 94.53% | 47.96% |
| CatakNet [16] | PCS’20 | RNN-based | 82.22% | 93.45% | 49.09% |
| ZhangNet [41] | AAAI’20 | RNN-based | 77.75% | 89.85% | 40.79% |
| BiLSTM [39] | arXiv’21 | RNN-based | 82.65% | 93.38% | 49.51% |
| MalBERT [48] | CS’21 | Transformer-based | 77.83% | 89.99% | 38.82% |
| LiNet [44] | CS’22 | CNN+RNN-based | 79.12% | 93.74% | 48.10% |
| Transformer [46] | CS’22 | Transformer-based | 75.95% | 91.07% | 37.83% |
| Mal-ASSF [45] | AS’23 | CNN+RNN-based | 82.36% | 93.81% | 48.66% |
| Nebula [47] | TIFS’24 | Transformer-based | 77.83% | 90.50% | 46.13% |
| Ours | - | CNN-based | 84.88 % | 95.82% | 63.15% |
| Sequence Length | Aliyun Binary Precision | Aliyun Binary Recall | Aliyun Binary ACC | Aliyun Multi Precision | Aliyun Multi Recall | Aliyun Multi ACC |
|---|---|---|---|---|---|---|
| 50 | 92.35% | 94.46% | 93.52% | 65.78% | 66.19% | 83.59% |
| 100 | 95.02 % | 96.13% | 95.82% | 66.23% | 67.10% | 84.88% |
| 150 | 94.46% | 95.41% | 95.38% | 65.89% | 66.53% | 84.03% |
| Grouped Convolution Kernels | Aliyun (Binary) Precision | Aliyun (Binary) Recall | Aliyun (Binary) ACC | Aliyun (Multi) Precision | Aliyun (Multi) Recall | Aliyun (Multi) ACC |
|---|---|---|---|---|---|---|
| 1, 3, 5 | 94.89% | 95.16% | 95.75% | 64.94% | 65.54% | 84.67% |
| 3, 3, 3 | 94.41% | 96.01% | 95.39% | 64.22% | 66.54% | 84.46% |
| 3, 4, 5 | 95.02% | 96.13% | 95.82% | 66.23% | 67.10% | 84.88% |
| 3, 5, 7 | 94.75% | 95.23% | 95.68% | 61.67% | 65.12% | 84.18% |
| 5, 7, 9 | 94.39% | 96.12% | 95.04% | 59.00% | 63.91% | 84.03% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Zhao, L.; Huang, H.; Li, N.; Wang, Y.; Li, M. LLM-SGCF: A Robust Malware Detection Framework with Spatially Guided Convolution. Computers 2026, 15, 329. https://doi.org/10.3390/computers15060329
Zhao L, Huang H, Li N, Wang Y, Li M. LLM-SGCF: A Robust Malware Detection Framework with Spatially Guided Convolution. Computers. 2026; 15(6):329. https://doi.org/10.3390/computers15060329
Chicago/Turabian StyleZhao, Lina, Hua Huang, Ning Li, Yunxiao Wang, and Ming Li. 2026. "LLM-SGCF: A Robust Malware Detection Framework with Spatially Guided Convolution" Computers 15, no. 6: 329. https://doi.org/10.3390/computers15060329
APA StyleZhao, L., Huang, H., Li, N., Wang, Y., & Li, M. (2026). LLM-SGCF: A Robust Malware Detection Framework with Spatially Guided Convolution. Computers, 15(6), 329. https://doi.org/10.3390/computers15060329

