Web security protection system based on openresty
OpenWAF
The first all-round open source Web security protection system, more protection than others.
This document describes OpenWAF v1.1 released on Mar 8, 2021.
Dockerfile and Docker Images have been upgraded to version 1.1 on Mar 8, 2021.
… #default_config-json
#main_safe_policy-json OpenWAF is the first fully open source Web application protection system (WAF), based on nginx_lua API analysis of HTTP request information. OpenWAF is composed of two functional engines: behavior analysis engine and rule engine. The rule engine mainly analyzes the individual requests, and the behavior analysis engine is mainly responsible for the tracking of the request information.
Rule engine inspired by modsecurity and freewaf(lua-resty-waf), the ModSecurity rules will be implemented using lua. The rule engine can be based on the protocol specification, automatic tools, injection attacks, cross site attacks, information leaks and other security exception request, adding support for dynamic rules, timely repair vulnerabilities.
Behavior analysis engine including fuzzy identification based on frequency, anti malware crawler, human-computer identification anti detection module, anti CSRF, anti CC, anti right, protection against attack file upload module, cookie tamper proof, anti-theft chain, custom headers and attack response page proof module of information disclosure.
In addition to the two engines, but also includes statistics, log, attack response page, access rules and other basic modules. In addition to the existing functional modules, OpenWAF also supports dynamic modification of the configuration, the dynamic addition of third party modules, so that the engine does not restart under the conditions of the outage, upgrade protection.
OpenWAF supports the above features as a strategy for different web application applications with different strategies to protect. The future will build a cloud platform, the strategy can also be shared for others.
basic modules:
safe modules:
Detailed configuration documents and examples, please refer to the above module documentation
The OpenWAF-en mailing list is for English speakers.
The OpenWAF-cn mailing list is for Chinese speakers.
579790127
Please submit bug reports, wishlists, or patches by
This module is licensed under the BSD license.
Copyright (C) 2016-2016, by Jian "Miracle" Qi (齐健) , Titan Co.Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
…syntax: "rules": table
default: none
context: twaf_access_rule
table类型,接入规则,顺序匹配
syntax: "user": string
default: -
context: twaf_access_rule:rules
string类型。用户名ID。对应变量 %{USERID}。
非必填,默认值"-".
syntax: "ngx_ssl": true|false
default: false
context: twaf_access_rule:rules
boolean类型,服务器端(nginx)认证开关,可与client_ssl组成双向认证
非必填,默认值false
syntax: "ngx_ssl_cert": "path"
default: none
context: twaf_access_rule:rules
string类型,服务器端(nginx)认证所需PEM证书地址,目前仅支持绝对地址
syntax: "ngx_ssl_key": "path"
default: none
context: twaf_access_rule:rules
string类型,服务器端(nginx)认证所需PEM私钥地址,目前仅支持绝对地址
syntax: "host": "ip|domain name regex"
default: none
context: twaf_access_rule:rules
string或数组类型。发布域名。(从 v1.0.0β 版本开始支持数组)
支持正则表达式(匹配时,自动忽略大小写)。
同时支持IPv4/IPv6。(从 v1.0.0β 版本开始支持IPv6)
例如:
"host": "^1\\.1\\.1\\.1$"
"host": "test\\.com"
"host": "^.*\\.com$"
"host": "www.baidu.com"
"host": ["www.baidu.com", "1.1.1.1", "8888::192.168.1.1"]syntax: "port": number
default: 80|443
context: twaf_access_rule:rules
number或数组类型,端口号。(从 v1.0.0β 版本开始支持数组)
非必填,默认值80或443
若"host"参数为数组时,"port"也应为数组。例如:
"host": ["www.baidu.com", "1.1.1.1", "8888::192.168.1.1"]
"posrt": [80, 8088, 8099]syntax: "path": "regex"
default: none
context: twaf_access_rule:rules
string类型,路径,支持正则匹配
非必填,默认值"/"
例如:
"path": "/"
"path": "/images"
"path": "/[a|b]test"syntax: "url_case_sensitive": "true|false"
default: false
context: twaf_access_rule:rules
boolean类型,路径区分大小写(从 v1.0.0β 版本开始支持此参数)
非必填,默认值false(不区分大小写)
syntax: "server_ssl": true|false
default: false
context: twaf_access_rule:rules
boolean类型,OpenWAF向后端服务器连接的ssl开关
非必填,默认值 false
例如:
upstream test {
server 1.1.1.1;
}
http {
server {
listen 80;
server_name _;
location / {
#server_ssl为true,相当于proxy_pass后为https
proxy_pass https://test;
#server_ssl为false,相当于proxy_pass后为http
#proxy_pass http://test;
}
}
}syntax: "forward": "upstream_uuid"
default: none
context: twaf_access_rule:rules
string类型,forward表示后端服务器的uuid,即upstream的名称
若不使用OpenWAF提供的$twaf_upstream_server变量,则"forward","forward_addr","forward_port"均非必填(从 v1.0.0β 版本开始支持非必填)
…syntax: "forward_addr": "ip"
default: none
context: twaf_access_rule:rules
string类型,forward_addr表示后端服务器的ip地址(TODO:支持域名)
upstream test {
#如:forward_addr值为1.1.1.1
server 1.1.1.1;
}syntax: "forward_port": port
default: 80|443
context: twaf_access_rule:rules
number类型,forward_port表示后端服务器端口号
非必填,默认值80或443
upstream test {
#如:forward_port值为50001
server 1.1.1.1:50001;
}syntax: "uuid": "string"
default: random(16)
context: twaf_access_rule:rules
string类型,接入规则的唯一标识
非必填,默认16位随机字符串(从 v1.0.0β 版本开始默认16位随机字符串)
syntax: "policy": "policy_uuid"
default: twaf_default_conf
context: twaf_access_rule:rules
string类型,满足此接入规则的请求,所使用安全策略的uuid
非必填,默认值twaf_default_conf
{
"twaf_anti_hotlink":{
"state":false,
"log_state":true,
"event_id":"110001",
"event_severity":"medium",
"ct_state":false,
"action_meta":403,
"action":"DENY",
"mode":"referer",
"allow_noreferer":true,
"cookie_name":"TWAF_AH",
"uri_ext":["javascript", "css", "html", ""]
}
}syntax: "state": true|false|"$dynamic_state"
default: false
context: twaf_anti_hotlink
当前模块暂未开源
syntax: "log_state": true|false|"$dynamic_state"
default: true
context: twaf_anti_hotlink
syntax: "ct_state": true|false|"$dynamic_state"
default: false
context: twaf_anti_hotlink
syntax: "event_id": "string"
default: "110001"
context: twaf_anti_hotlink
syntax: "event_severity": "string"
default: "medium"
context: twaf_anti_hotlink
syntax: "action": "string"
default: "DENY"
context: twaf_anti_hotlink
syntax: "action_meta": "string"|number
default: 403
context: twaf_anti_hotlink
syntax: *"mode": "str
No open issues yet, or sync has not completed.