Real-Time Code Vulnerability Detection Using a Machine Learning-Integrated Language Server
Abstract
The rapid growth of software development has improved productivity but also introduced security risks, especially when developers skip essential scans due to time constraints or limited tool support. This study proposes a real-time vulnerability detection system that integrates machine learning (ML) into a language server framework to enhance software security during coding. The system uses a Language Server Protocol (LSP) architecture with a Random Forest classifier that analyzes source code at the line level. Code is pre-processed through tokenization, abstract syntax tree (AST) traversal, and TF-IDF vectorization before being classified into four vulnerability types: CWE-79 (Cross-Site Scripting), CWE-89 (SQL Injection), CWE-22 (Path Traversal), and CWE-434 (Unrestricted File Upload). Using 20,000 labeled code lines, the model achieves 82.3% accuracy and an F1-score of 80.7%, performing best on CWE-79 and CWE-89 and showing weakest performance on CWE-434. The language server averages 72 ms per diagnostic, demonstrating its suitability for real-time developer workflows.
Fields of Study & Subjects
Web Application Security Vulnerabilities
Software Engineering Research
Software Testing and Debugging Techniques
Publication details
- Journal / source
- Proceedings of Engineering and Technology Innovation
- Volume
- 32
- Pages
- 28–42
- Publication date
- 1 January 2026
- Language
- EN