Self-hosted WAF lab workflow with developer workstation, test domain, WAF node, upstream application, logs, latency evidence, and rollback path.
该实验把受控请求先送入 OWASP CRS 与 ModSecurity,再转发到一个简单上游应用。
  • 开发者工作站
  • 实验域名
  • OWASP CRS + ModSecurity
  • NGINX 反向代理
  • 上游 Demo 应用
  • 证据:状态码、规则、延迟
  • 回滚路径

实验状态

对象
OWASP CRS / ModSecurity / NGINX
状态
已完成冒烟实测
更新
2026-07-09

证据原则

WAFWiki 会区分已验证的动手实测、冒烟实测、架构图和方法论说明。任何本地实验都只证明记录环境中的有限路径,不代表完整生产就绪。

环境

可复现信息

宿主运行环境

Docker Desktop 29.2.0 on macOS, aarch64

WAF 镜像

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

命令

如何复现实验

启动上游 Demo 服务

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 路由。

运行 OWASP CRS、ModSecurity 与 NGINX

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:nginx

WAF 容器在 localhost 启动,并代理到上游 Demo 服务。

对比正常请求与 SQLi-like 实验请求

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 规则证据。

观察结果

本轮动手实测说明了什么

正常请求

HTTP 200

GET /health 经由 WAF 路径到达上游 JSON 服务。

SQLi-like 实验请求

HTTP 403

GET /search?id=1 or 1=1 被 WAF 中断。

主要检测

Rule 942100

CRS 记录了 SQL Injection Attack Detected via libinjection。

阻断决策

Rule 949110

入站异常分数达到配置阈值 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 original smoke-test evidence is preserved as a safe terminal capture.

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.

Terminal-style screenshot of WAFWiki ModSecurity CRS Docker smoke-test evidence.

限制

这个结果不能证明什么

相关研究

继续研究 OWASP CRS / ModSecurity / NGINX