[Paper Review] Machine learning-assisted virtual patching of web applications
This paper proposes a machine learning-enhanced virtual patching approach for web applications using one-class classification and n-gram analysis to improve ModSecurity’s detection accuracy and reduce false positives. The method outperforms the default OWASP Core Rule Set by leveraging normal traffic patterns for anomaly detection, with both models enabling deployment in low- or high-data scenarios.
Web applications are permanently being exposed to attacks that exploit their vulnerabilities. In this work we investigate the application of machine learning techniques to leverage Web Application Firewall (WAF), a technology that is used to detect and prevent attacks. We propose a combined approach of machine learning models, based on one-class classification and n-gram analysis, to enhance the detection and accuracy capabilities of MODSECURITY, an open source and widely used WAF. The results are promising and outperform MODSECURITY when configured with the OWASP Core Rule Set, the baseline configuration setting of a widely deployed, rule-based WAF technology. The proposed solution, combining both approaches, allow us to deploy a WAF when no training data for the application is available (using one-class classification), and an improved one using n-grams when training data is available.
Motivation & Objective
- Address the high false positive rate and rigidity of rule-based Web Application Firewalls (WAFs), such as ModSecurity with OWASP Core Rule Set.
- Improve WAF detection capabilities by learning normal application behavior using machine learning, especially in the absence of labeled attack data.
- Develop a complementary approach that combines one-class classification for zero-day resilience and n-gram analysis for high-accuracy detection when training data is available.
- Enable practical deployment of intelligent WAFs in real-world scenarios where source code is unavailable or patching is infeasible.
- Provide a framework for integrating machine learning into existing WAFs like ModSecurity to reduce manual tuning and improve security posture.
Proposed method
- Use one-class classification to model normal web request behavior based on features derived from known attack patterns, enabling detection of anomalies without labeled attack data.
- Apply n-gram analysis to model the statistical distribution of input sequences across web parameters, using variable-length n-grams (up to a configurable n) to capture structural patterns.
- Configure n-gram length per field (e.g., shorter n for sparse fields like emails) to optimize sensitivity and reduce sparsity issues.
- Train the n-gram model on legitimate traffic to learn expected input distributions, flagging deviations as potential attacks.
- Combine outputs from both models via label fusion (normal/attack) to improve detection robustness and adaptability.
- Integrate the ML models as a plugin layer on top of ModSecurity, using its logging and inspection pipeline for real-time traffic analysis.
Experimental results
Research questions
- RQ1Can one-class classification improve WAF detection in scenarios with no available training data for the application?
- RQ2How effective is n-gram-based anomaly detection in identifying malicious payloads when trained on normal traffic?
- RQ3Can the combination of one-class classification and n-gram analysis outperform the default OWASP Core Rule Set in both detection rate and false positive rate?
- RQ4How do model parameters (e.g., n-gram length, feature selection) affect performance across diverse web application types?
- RQ5To what extent can ML-based virtual patching reduce the need for manual rule tuning in production WAF deployments?
Key findings
- The one-class classification model achieved better detection and false positive rates than ModSecurity with the OWASP Core Rule Set when no application-specific training data was available.
- The n-gram-based anomaly detection model significantly outperformed ModSecurity’s default configuration on two of the three test datasets, demonstrating superior accuracy in identifying malicious inputs.
- The combination of both models provided a robust solution that could be deployed in both data-scarce (one-class) and data-rich (n-gram) scenarios.
- The proposed method reduced the need for manual rule tuning by identifying false positives in ModSecurity logs, which could be used to refine the rule set.
- The n-gram model showed strong resilience to zero-day attacks by detecting deviations from expected input patterns, even without prior knowledge of the attack.
- The framework demonstrated practical feasibility for integration into existing WAFs like ModSecurity, with a clear path toward native module development.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.