A hybrid CNN-BiLSTM-attention framework with class-aware gating for network intrusion detection

(1) * Mohammed Saeed Hamid Mail (Shahrood University of Technology, Iran, Islamic Republic of)
(2) Mohsen Rezvani Mail (Shahrood University of Technology, Iran, Islamic Republic of)
(3) Esmaeel Tahanian Mail (Shahrood University of Technology, Iran, Islamic Republic of)
*corresponding author

Abstract


Network intrusion detection is challenging because traffic features are high-dimensional and attack classes are highly imbalanced. This study evaluates a hybrid CNN-BiLSTM-Attention framework with class-aware gating for multiclass intrusion detection using CICIDS2017. Random Forest-based feature selection retained 51 of 78 numerical traffic features. Each flow was represented as an ordered feature vector, not as a chronological traffic sequence. The original evaluation across 13 traffic categories yielded 98.78% accuracy, 98.76% weighted F1-score, and 81.26% macro F1-score. However, recall was only 38.93% for Bot, 11.24% for Web Attack, and 0% for Infiltration. A Random Forest baseline using the same 51 features achieved 99.49% accuracy and 93.14% macro F1-score, outperforming the hybrid model on both measures. In a separate stratified 60/20/20 ablation study, the gating configuration outperformed the attention-only variant but did not outperform the simpler CNN-BiLSTM model. In the original evaluation, mean imputation was performed before the train-test split, introducing a potential source of information leakage. The findings characterize the architecture’s measured performance and its limitations regarding minority-class detection, comparative effectiveness, and evaluation methodology.

Keywords


Intrusion detection; CICIDS2017; Deep learning; CNN; BiLSTM; Multi-Head Attention; Class-Aware Gating; Feature selection; Random Forest; Network security

   

DOI

https://doi.org/10.26555/ijain.v12i4.2613
      

Article metrics

Abstract views : 0

   

Cite

   

References


[1] M. A. Ferrag, L. Maglaras, S. Moschoyiannis, and H. Janicke, “Deep learning for cyber security intrusion detection: Approaches, datasets, and comparative study,” J. Inf. Secur. Appl., vol. 50, no. February, p. 102419, Feb. 2020, doi: 10.1016/j.jisa.2019.102419.

[2] S. Gamage and J. Samarabandu, “Deep learning methods in network intrusion detection: A survey and an objective comparison,” J. Netw. Comput. Appl., vol. 169, no. November, p. 102767, Nov. 2020, doi: 10.1016/j.jnca.2020.102767.

[3] O. F. Hassan et al., “Enhancing Cybersecurity through Cloud Computing Solutions in the United States,” Intell. Inf. Manag., vol. 16, no. 04, pp. 176–193, 2024, doi: 10.4236/iim.2024.164011.

[4] Rakhi A. Kalantri, “Advancing Cyber Threat Detection with Ai: Cutting-Edge Techniques and Future Trends,” J. Inf. Syst. Eng. Manag., vol. 10, no. 14s, pp. 338–352, Feb. 2025, doi: 10.52783/jisem.v10i14s.2301.

[5] K. M, “An Intelligent Machine Learning Framework for Cyber Security Threat Detection,” Int. Res. J. Educ. Technol., vol. 6, no. 11, pp. 331–335, Nov. 2024, doi: 10.70127/irjedt.vol.9.issue07.331.

[6] M. L. Ali, K. Thakur, S. Schmeelk, J. Debello, and D. Dragos, “Deep Learning vs. Machine Learning for Intrusion Detection in Computer Networks: A Comparative Study,” Appl. Sci., vol. 15, no. 4, p. 1903, Feb. 2025, doi: 10.3390/app15041903.

[7] S. L. Jacob and P. Sultana Habibullah, “A Systematic Analysis and Review on Intrusion Detection Systems Using Machine Learning and Deep Learning Algorithms,” J. Comput. Cogn. Eng., vol. 4, no. 2, pp. 108–120, Jul. 2024, doi: 10.47852/bonviewJCCE42023249.

[8] M. A. Talukder et al., “Machine learning-based network intrusion detection for big and imbalanced data using oversampling, stacking feature embedding and feature extraction,” J. Big Data, vol. 11, no. 1, p. 33, Feb. 2024, doi: 10.1186/s40537-024-00886-w.

[9] S. V. Bhaskar, L. V. V. G. Rao, and A. G. Krishna, “Customized LSTM Models with Bi-Directional Architectures,” in 2024 International Conference on Science Technology Engineering and Management (ICSTEM), IEEE, Apr. 2024, pp. 1–7. doi: 10.1109/ICSTEM61137.2024.10560518.

[10] N. Dissanayake and U. Thayasivam, “Attack-Specialized Deep Learning with Ensemble Fusion for Network Anomaly Detection,” arXiv, vol. 2, pp. 1–8, Nov. 2025, [Online]. Available: http://arxiv.org/abs/2510.12455

[11] P. Wang, P. Sang, and P. Gao, “An Attention-Enhanced CNN-BiGRU Framework for Intrusion Detection,” Int. J. Comput. Intell. Appl., vol. 25, no. 02, p. 2650006, Jun. 2026, doi: 10.1142/S1469026826500069.

[12] Y. Gujarathi and Y. Potekar, “Machine Learning in Network Traffic Analysis: Classification, Optimization, and Security,” Int. J. Res. Appl. Sci. Eng. Technol., vol. 13, no. 4, pp. 455–459, Apr. 2025, doi: 10.22214/ijraset.2025.68216.

[13] M. Al-Omari and Q. A. Al-Haija, “Towards Robust IDSs: An Integrated Approach of Hybrid Feature Selection and Machine Learning,” J. Internet Serv. Inf. Secur., vol. 14, no. 3, pp. 47–67, Aug. 2024, doi: 10.58346/JISIS.2024.I2.004.

[14] L. Breiman, “Random Forests,” Mach. Learn., vol. 45, no. 1, pp. 5–32, Oct. 2001, doi: 10.1023/A:1010933404324.

[15] M. Al Lail, A. Garcia, and S. Olivo, “Machine Learning for Network Intrusion Detection—A Comparative Study,” Futur. Internet, vol. 15, no. 7, p. 243, Jul. 2023, doi: 10.3390/fi15070243.

[16] P. Dini, A. Elhanashi, A. Begni, S. Saponara, Q. Zheng, and K. Gasmi, “Overview on Intrusion Detection Systems Design Exploiting Machine Learning for Networking Cybersecurity,” Appl. Sci., vol. 13, no. 13, p. 7507, Jun. 2023, doi: 10.3390/app13137507.

[17] P. A. A. Resende and A. C. Drummond, “A Survey of Random Forest Based Methods for Intrusion Detection Systems,” ACM Comput. Surv., vol. 51, no. 3, pp. 1–36, May 2019, doi: 10.1145/3178582.

[18] F. Charmet et al., “Explainable artificial intelligence for cybersecurity: a literature survey,” Ann. Telecommun., vol. 77, no. 11–12, pp. 789–812, Dec. 2022, doi: 10.1007/s12243-022-00926-7.

[19] I. Sharafaldin, A. Habibi Lashkari, and A. A. Ghorbani, “Toward Generating a New Intrusion Detection Dataset and Intrusion Traffic Characterization,” in Proceedings of the 4th International Conference on Information Systems Security and Privacy, SCITEPRESS - Science and Technology Publications, 2018, pp. 108–116. doi: 10.5220/0006639801080116.

[20] Z. Xu and Y. Liu, “Robust Anomaly Detection in Network Traffic: Evaluating Machine Learning Models on CICIDS2017,” in 2025 10th International Conference on Electronic Technology and Information Science (ICETIS), 2025, pp. 475–482. doi: 10.1109/ICETIS66286.2025.11144025.

[21] A.-R. Al-Ghuwairi, Y. Sharrab, D. Al-Fraihat, M. AlElaimat, A. Alsarhan, and A. Algarni, “Intrusion detection in cloud computing based on time series anomalies utilizing machine learning,” J. Cloud Comput., vol. 12, no. 1, p. 127, Aug. 2023, doi: 10.1186/s13677-023-00491-x.

[22] M. Ali et al., “Effective network intrusion detection using stacking-based ensemble approach,” Int. J. Inf. Secur., vol. 22, no. 6, pp. 1781–1798, Dec. 2023, doi: 10.1007/s10207-023-00718-7.

[23] S. Hochreiter and J. Schmidhuber, “Long Short-Term Memory,” Neural Comput., vol. 9, no. 8, pp. 1735–1780, Nov. 1997, doi: 10.1162/neco.1997.9.8.1735.

[24] K. Mohiuddin et al., “Retention is All You Need,” in Proceedings of the 32nd ACM International Conference on Information and Knowledge Management, New York, NY, USA: ACM, Oct. 2023, pp. 4752–4758. doi: 10.1145/3583780.3615497.

[25] D. S. Berman, A. L. Buczak, J. S. Chavis, and C. L. Corbett, “A Survey of Deep Learning Methods for Cyber Security,” Information, vol. 10, no. 4, p. 122, Apr. 2019, doi: 10.3390/info10040122.

[26] A. A. Awad, A. F. Ali, and T. Gaber, “An improved long short term memory network for intrusion detection,” PLoS One, vol. 18, no. 8, p. e0284795, Aug. 2023, doi: 10.1371/journal.pone.0284795.

[27] D. Gumusbas, T. Yldrm, A. Genovese, and F. Scotti, “A Comprehensive Survey of Databases and Deep Learning Methods for Cybersecurity and Intrusion Detection Systems,” IEEE Syst. J., vol. 15, no. 2, pp. 1717–1731, Jun. 2021, doi: 10.1109/JSYST.2020.2992966.

[28] M. Soltani, B. Ousat, M. Jafari Siavoshani, and A. H. Jahangir, “An adaptable deep learning-based intrusion detection system to zero-day attacks,” J. Inf. Secur. Appl., vol. 76, p. 103516, Aug. 2023, doi: 10.1016/j.jisa.2023.103516.

[29] R. R. Rajendran, D., Maniar, V., Tamilmani, V., Namburi, V. D., Singh, A. A. S., & Kothamaram, “CNN-LSTM Hybrid Architecture for Accurate Network Intrusion Detection for Cybersecurity. Journal Of Engineering And Computer Sciences, 2(11), 1-13.,” SARC-PUBLISHER, vol. 02, no. 11, pp. 1–13, 2023, [Online]. Available: https://zenodo.org/records/17516985

[30] D. R, L. M, M. V, and S. S, “Data Securing Using LSTM-CNN Model,” in 2023 Intelligent Computing and Control for Engineering and Business Systems (ICCEBS), IEEE, Dec. 2023, pp. 1–4. doi: 10.1109/ICCEBS58601.2023.10448747.

[31] X. Dong and Y. Liu, “A CNN-BiLSTM-Attention Model for Network Anomaly Traffic Detection,” in 2025 IEEE International Conference on Pattern Recognition, Machine Vision and Artificial Intelligence (PRMVAI), IEEE, Jun. 2025, pp. 1–7. doi: 10.1109/PRMVAI65741.2025.11108334.

[32] A. McCarthy, E. Ghadafi, P. Andriotis, and P. Legg, “Defending against adversarial machine learning attacks using hierarchical learning: A case study on network traffic attack classification,” J. Inf. Secur. Appl., vol. 72, no. February, p. 103398, Feb. 2023, doi: 10.1016/j.jisa.2022.103398.

[33] A. M. Musolf, E. R. Holzinger, J. D. Malley, and J. E. Bailey-Wilson, “What makes a good prediction? Feature importance and beginning to open the black box of machine learning in genetics,” Hum. Genet., vol. 141, no. 9, pp. 1515–1528, Sep. 2022, doi: 10.1007/s00439-021-02402-z.

[34] Z. A. Varzaneh and S. Hosseini, “An improved equilibrium optimization algorithm for feature selection problem in network intrusion detection,” Sci. Rep., vol. 14, no. 1, p. 18696, Aug. 2024, doi: 10.1038/s41598-024-67488-7.

[35] A. Nisioti, A. Mylonas, P. D. Yoo, and V. Katos, “From Intrusion Detection to Attacker Attribution: A Comprehensive Survey of Unsupervised Methods,” IEEE Commun. Surv. Tutorials, vol. 20, no. 4, pp. 3369–3388, 2018, doi: 10.1109/COMST.2018.2854724.

[36] B. Krawczyk, “Learning from imbalanced data: open challenges and future directions,” Prog. Artif. Intell., vol. 5, no. 4, pp. 221–232, Nov. 2016, doi: 10.1007/s13748-016-0094-0.

[37] N. V. Chawla, K. W. Bowyer, L. O. Hall, and W. P. Kegelmeyer, “SMOTE: Synthetic Minority Over-sampling Technique,” J. Artif. Intell. Res., vol. 16, pp. 321–357, Jun. 2002, doi: 10.1613/jair.953.

[38] M. Azizjon, A. Jumabek, and W. Kim, “1D CNN based network intrusion detection with normalization on imbalanced data,” in 2020 International Conference on Artificial Intelligence in Information and Communication (ICAIIC), IEEE, Feb. 2020, pp. 218–224. doi: 10.1109/ICAIIC48513.2020.9064976.

[39] S. S.p. and S. K. Balasubramanian, “Advancing Multi-Class Intrusion Detection: A Comparative Evaluation of LSTM and Bi-LSTM on Class-Imbalanced CIC-IDS-2017,” Turkish J. Eng., vol. 9, no. 3, pp. 578–590, Jul. 2025, doi: 10.31127/tuje.1658662.

[40] T. Saito and M. Rehmsmeier, “The Precision-Recall Plot Is More Informative than the ROC Plot When Evaluating Binary Classifiers on Imbalanced Datasets,” PLoS One, vol. 10, no. 3, p. e0118432, Mar. 2015, doi: 10.1371/journal.pone.0118432.




Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

___________________________________________________________
International Journal of Advances in Intelligent Informatics
ISSN 2442-6571  (print) | 2548-3161 (online)
Organized by UAD and ASCEE Computer Society
Published by Universitas Ahmad Dahlan
W: http://ijain.org
E: info@ijain.org (paper handling issues)
 andri.pranolo.id@ieee.org (publication issues)

View IJAIN Stats

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0