宿主运行环境
Docker Desktop 29.2.0 on macOS, aarch64
WAFWiki 原创实验
一份可复现的 OWASP CRS、ModSecurity 与 NGINX 本地冒烟实测,覆盖正常请求、安全测试载荷、证据日志和上线限制。

证据原则
WAFWiki 会区分已验证的动手实测、冒烟实测、架构图和方法论说明。任何本地实验都只证明记录环境中的有限路径,不代表完整生产就绪。
环境
Docker Desktop 29.2.0 on macOS, aarch64
owasp/modsecurity-crs:nginx
sha256:5beec1cf50e9518821d11862b988809936b2abb43ed8a930a714130df39318ff
ModSecurity-nginx v1.0.4, libmodsecurity3 v3.0.16
OWASP CRS 3.3.10, blocking paranoia level 1
Upstream 127.0.0.1:18080, WAF 127.0.0.1:18081
命令
python3 -m http.server 18080 --bind 127.0.0.1
# In the published lab we used a tiny JSON handler instead of serving a directory.上游服务应先能在本地直接响应,再引入 WAF 路由。
docker run --rm -d --name wafwiki-crs-lab \
-p 127.0.0.1:18081:8080 \
-e BACKEND=http://host.docker.internal:18080 \
-e MODSEC_RULE_ENGINE=on \
-e BLOCKING_PARANOIA=1 \
-e ANOMALY_INBOUND=5 \
owasp/modsecurity-crs:nginxWAF 容器在 localhost 启动,并代理到上游 Demo 服务。
curl -H 'Host: lab.wafwiki.local' http://127.0.0.1:18081/health
curl -H 'Host: lab.wafwiki.local' 'http://127.0.0.1:18081/search?id=1%20or%201%3D1'正常请求返回 200;SQLi-like 实验请求返回 403,并产生 CRS 规则证据。
观察结果
正常请求
GET /health 经由 WAF 路径到达上游 JSON 服务。
SQLi-like 实验请求
GET /search?id=1 or 1=1 被 WAF 中断。
主要检测
CRS 记录了 SQL Injection Attack Detected via libinjection。
阻断决策
入站异常分数达到配置阈值 5。
Clean request: http_code=200 total=0.009809
SQLi-like lab request: http_code=403 total=0.008503
ModSecurity-nginx v1.0.4 loaded 929 local rules.
libmodsecurity3 version 3.0.16 was reported at startup.
CRS message: SQL Injection Attack Detected via libinjection.
CRS blocking message: Inbound Anomaly Score Exceeded (Total Score: 5).证据上下文
The screenshot records the clean and SQLi-like HTTP outcomes, engine and connector versions, CRS detection message, and blocking rule without exposing unrelated local data.

限制
相关研究