ModSecurity is widely recognized as the standard open-source Web Application Firewall (WAF), maintained by the OWASP Foundation. It detects malicious requests by matching them against the Core Rule Set, identifying well-known attack patterns. Each rule in the CRS is manually assigned a weight, based on the severity of the corresponding attack, and a request is detected as malicious if the sum of the weights of the firing rules exceeds a given threshold. In this work, we show that this simple strategy is largely ineffective for detecting SQL injection (SQLi) attacks, as it tends to block many legitimate requests, while also being vulnerable to adversarial SQLi attacks, i.e., attacks intentionally manipulated to evade detection. To overcome these issues, we design a robust machine learning model, named AdvModSec, which uses the CRS rules as input features, and it is trained to detect adversarial SQLi attacks. Our experiments show that AdvModSec, being trained on the traffic directed towards the protected web services, achieves a better trade-off between detection and false positive rates, improving the detection rate of the vanilla version of ModSecurity with CRS by 21%. Moreover, our approach is able to improve its adversarial robustness against adversarial SQLi attacks by 42%, thereby taking a step forward towards building more robust and trustworthy WAFs.
翻译:ModSecurity被公认为由OWASP基金会维护的标准开源Web应用防火墙(WAF)。它通过将恶意请求与核心规则集(CRS)进行匹配来识别已知攻击模式。CRS中的每条规则均根据对应攻击的严重程度被手动赋予权重,若触发规则的权重之和超过给定阈值,则该请求被判定为恶意。本研究表明,这种简单策略在检测SQL注入攻击方面基本无效,因为它既会拦截大量合法请求,又容易受到对抗性SQL注入攻击(即有意规避检测的攻击)的影响。为解决这些问题,我们设计了一个名为AdvModSec的鲁棒机器学习模型,该模型将CRS规则作为输入特征,并经过训练以检测对抗性SQL注入攻击。实验表明,AdvModSec通过针对受保护Web服务流量进行训练,在检测率与误报率之间实现了更优的权衡,相较于使用CRS的基础版ModSecurity,检测率提升了21%。此外,我们的方法能将对抗性SQL注入攻击的鲁棒性提高42%,从而向构建更鲁棒、更可信的WAF迈进一步。