Files
qing d036af935f feat(waf): 启用 OWASP CRS 异常评分制自动拦截
- SecRuleEngine On 自动拦截异常评分达阈值的请求(规则 949110)
- 新增 rules/local/tuning.conf 调优文件(偏执等级 1 + 阈值 5/4)
- tuning.conf 独立于自动生成的 crs/coraza.conf,重跑 fetch 不覆盖
2026-08-04 20:40:25 +08:00

33 lines
1.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# tuning.conf —— OWASP CRS 调优(异常评分制)
# 本文件独立于 crs/coraza.conf(后者由 _fetch_crs.sh 自动生成,重跑会被覆盖)。
# engine 加载顺序:local/*.conf 在 crs/*.conf 之前,故此处 setvar 先于 CRS 规则生效。
#
# 自动拦截机制(waf.conf 已设为 On):
# 每条规则命中按严重度累加异常分(CRITICAL=5 / ERROR=4 / WARNING=3 / NOTICE=2),
# 当 tx.anomaly_score >= tx.inbound_anomaly_score_threshold 时,规则 949110 自动 deny。
# 低分请求放行、高分请求拦截,全自动,无需人工干预。
#
# 调参旋钮:
# - 偏执等级 1(paranoia_level=1):只用最基础规则集,误报最少
# - 异常评分阈值(inbound 5 / outbound 4):
# · 数值越小越敏感、误报越多;越大越宽松、漏报越多
# · 若线上误报偏多,调大阈值(如 7/8);漏报偏多则调小
#
# 调参后执行:kill -HUP <pid> 热加载生效。
# 偏执等级(1 最保守;2/3/4 递增更严、误报更多)
SecAction \
"id:900000,\
phase:1,\
pass,\
nolog,\
setvar:tx.blocking_paranoia_level=1"
# 异常评分阈值
SecAction \
"id:900110,\
phase:1,\
pass,\
nolog,\
setvar:tx.inbound_anomaly_score_threshold=5,\
setvar:tx.outbound_anomaly_score_threshold=4"