Improving Cross-Project Java Vulnerability Prediction Using Genetic Algorithm-Based Feature Optimization and Random Forest Classification

Keywords: Vulnerability, Metrics, Cross-project, Correlation, Model

Abstract

Software vulnerabilities in Java applications remain a critical security concern due to increasing system complexity and the limitations of traditional static analysis tools, which often generate high false-positive rates. Although machine learning-based Vulnerability Prediction Models (VPMs) have improved vulnerability detection, they continue to face challenges related to generalization and robustness, particularly in cross-project settings. This study proposes a Java vulnerability prediction framework that combines optimized feature selection with Random Forest (RF) classification. The key contributions of this study are twofold: (i) the construction of a new vulnerability prediction dataset that integrates traditional software metrics with vulnerability-oriented features extracted from static analysis tools, thereby providing a richer feature representation than conventional benchmark datasets, and (ii) a modified Genetic Algorithm incorporating an Extreme Two Genes (ETG) crossover operator and correlation-based fitness evaluation for enhanced feature optimization. Random oversampling is employed to address class imbalance. Experiments were conducted on Apache Tomcat 9.0.0.M1 (372 instances) and Eclipse Jetty 9.4.0.RC1 (324 instances). The proposed framework achieved within-project performance of 94% precision, 95% recall, and 95% F1-score for Tomcat, and 95% precision, 98% recall, and 95% F1-score for Jetty. Cross-project evaluation produced F1-scores of 76.9% and 70.9%. The results demonstrate that the proposed ETG-enhanced feature optimization framework improves vulnerability prediction performance, achieving strong within-project results while maintaining useful predictive capability across projects. Although cross-project prediction remains challenging and performance decreases relative to within-project prediction, the framework demonstrates robustness under cross-project variability and provides a foundation for more generalizable vulnerability prediction in Java software systems.

Author Biography

Michael A. Olatunji, Redeemer's University, Ede, Osun State
Department of Cybersecurity, Lecturer II

References

Bajantri, G., & Shariff, N. C. (2025). Enhancing software security with CNN-LSTM hybrid model: Vulnerability detection [Preprint]. Research Square. https://doi.org/10.21203/rs.3.rs-8151185/v1

Bassi, D., & Singh, H. (2024). A comparative analysis of metaheuristic feature selection methods in software vulnerability prediction. e-Informatica Software Engineering Journal, 19(1), 250103.

Dam, H. K., Tran, T., Pham, T., Ng, S. W., Grundy, J., & Ghose, A. (2017). Automatic feature learning for vulnerability prediction (arXiv Preprint No. arXiv:1708.02368). arXiv. https://arxiv.org/abs/1708.02368

Gunda, S. K. (2025, July). Automatic Software Vulnerabilty Detection Using Code Metrics and Feature Extraction. In 2025 2nd International Conference On Multidisciplinary Research and Innovations in Engineering (MRIE) (pp. 115-120). IEEE.

Hussian, S., Ghafoor, M. I., Perviaz, P., & Fakhar, S. (2025). Code-semantic based intelligent vulnerabilities detector. Spectrum of Engineering Sciences, 117–130.

Hussain, S., Nadeem, M., Baber, J., Hamdi, M., Rajab, A., Al Reshan, M. S., & Shaikh, A. (2024). Vulnerability detection in Java source code using a quantum convolutional neural network with self-attentive pooling, deep sequence, and graph-based hybrid feature extraction. Scientific Reports, 14(1), 7406.

Khare, A., Dutta, S., Li, Z., Solko-Breslin, A., Alur, R., & Naik, M. (2025, March). Understanding the effectiveness of large language models in detecting security vulnerabilities. In 2025 IEEE Conference on Software Testing, Verification and Validation (ICST) (pp. 103–114). IEEE.

Le, T. H. M., & Babar, M. A. (2024, October). Mitigating data imbalance for software vulnerability assessment: Does data augmentation help? In Proceedings of the 18th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement (pp. 119–130).

Manjula, C., & Florence, L. (2018). Hybrid approach for software defect prediction using machine learning with optimization technique. International Journal of Computer and Information Engineering, 12(1), 28–32.

Mächtle, F., Loose, N., Schulz, T., Sieck, F., Serr, J. N., Möller, R., & Eisenbarth, T. (2025). Trace gadgets: Minimizing code context for machine learning-based vulnerability prediction. arXiv preprint arXiv:2504.13676.

Nguyen, D., Tran-Duc, M., Le-Cong, T., Le, T. H. M., Babar, M. A., & Huynh, Q. T. (2025). VulGuard: An unified tool for evaluating just-in-time vulnerability prediction models. In 2025 IEEE International Conference on Software Maintenance and Evolution (ICSME) (pp. 945–949). IEEE.

Osman, H., Ghafari, M., Nierstrasz, O., & Lungu, M. (2017). An extensive analysis of efficient bug prediction configurations. In Proceedings of the 13th International Conference on Predictive Models and Data Analytics in Software Engineering (PROMISE 2017).

Scandariato, R., Walden, J., Hovsepyan, A., & Joosen, W. (2014). Predicting vulnerable software components via text mining. IEEE Transactions on Software Engineering, 40(11), 993–1006.

Shamal, P. K., Rahamathulla, K., & Akbar, A. (2017, March). A study on software vulnerability prediction model. In 2017 International Conference on Wireless Communications, Signal Processing and Networking (WiSPNET) (pp. 703-706). IEEE.

Sultana, K. Z., Anu, V., & Chong, T. Y. (2024). Using software metrics for predicting vulnerable classes in java and python based systems. Information Security Journal: A Global Perspective, 33(3), 251-267.

Thomas, N. S., & Kaliraj, S. (2024). An improved and optimized random forest based approach to predict the software faults. SN Computer Science, 5(5), 530.

Tran, N. K., & Cheng, W. (2018). Multiplicative tree-structured long short-term memory networks for semantic representations. In Proceedings of the Seventh Joint Conference on Lexical and Computational Semantics (pp. 276-286).

Wang, H., Tang, Z., Tan, S. H., Wang, J., Liu, Y., Fang, H., Xia, C., & Zheng, W. (2024). Combining structured static code information and dynamic symbolic traces for software vulnerability prediction. In Proceedings of the 46th IEEE/ACM International Conference on Software Engineering (ICSE 2024) (pp. 169:1–169:13).

Zhao, S., Zhu, J., & Peng, J. (2024). Software vulnerability mining and analysis based on deep learning. Computers, Materials & Continua, 80(2), 3263.

Published
2026-09-26