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被广泛认为是标准开源Web应用防火墙(WAF),由OWASP基金会维护。它通过将恶意请求与核心规则集匹配来检测恶意请求,识别已知攻击模式。CRS中的每条规则根据相应攻击的严重程度被手动分配一个权重,若触发规则的权重总和超过给定阈值,则该请求被判定为恶意。本研究表明,这种简单策略在检测SQL注入(SQLi)攻击时效果欠佳:一方面会拦截大量合法请求,另一方面容易受到对抗性SQLi攻击(即有意篡改以规避检测的攻击)的威胁。为解决这些问题,我们设计了一个名为AdvModSec的鲁棒机器学习模型,该模型以CRS规则作为输入特征,并专门训练以检测对抗性SQLi攻击。实验表明,AdvModSec通过针对受保护Web服务的流量进行训练,在检测率与误报率之间取得了更优的平衡,相比使用CRS的标准版ModSecurity,检测率提升了21%。此外,该方法对对抗性SQLi攻击的鲁棒性提高了42%,从而向构建更鲁棒、更可信的WAF迈出了重要一步。