1- <?xml version =" 1.0" encoding =" UTF-8" ?>
2-
3- <!--
4- This file defines a set of "web application firewall" rules that
5- defend a web application against certain types of attacks. These rules
6- are loaded and enforced by a filter that sits in front of a web
7- application and has access to both request and response on both the
8- way in and the way out.
9- -->
10-
11- <policy >
12-
13-
14- <!--
15- Setup some simple aliases to use elsewhere in the WAF policy. Alias
16- types are: string (default), regex. String is a literal string, regex
17- is a pattern.
18- -->
19- <aliases >
20- <alias name =" INPUT_VALIDATION_ERROR" >/security/input.jsp</alias >
21- <alias name =" ADMIN_PATH" type =" regex" >^/admin/.*</alias >
22- </aliases >
23-
24-
25-
26- <!--
27- Set the overall WAF mode of operation. The mode can be either "block"
28- or "log". "block" mode will send all errors to the web page defined in
29- the error-handling configuration. "log" mode will not change HTTP
30- requests at all, but will simply log errors.
31- -->
32- <settings >
33- <mode >redirect</mode >
34- <session-cookie-name >JSESSIONID</session-cookie-name >
35- <error-handling >
36- <default-redirect-page >/security/error.jsp</default-redirect-page >
37- <block-status >403</block-status >
38- </error-handling >
39- </settings >
40-
41-
42-
43- <!--
44- Set authentication rules by path.
45- -->
46- <authentication-rules path =" /.*" key =" ESAPIUserSessionKey" >
47- <path-exception >/</path-exception >
48- <path-exception >/index.html</path-exception >
49- <path-exception >/login.jsp</path-exception >
50- <path-exception >/index.jsp</path-exception >
51- <path-exception type =" regex" >/images/.*</path-exception >
52- <path-exception type =" regex" >/css/.*</path-exception >
53- <path-exception type =" regex" >/help/.*</path-exception >
54- </authentication-rules >
55-
56-
57- <bean-shell-rules >
58- <!-- <bean-shell-script
59- id="example1"
60- file="waf-policies/bean-shell-rule.bsh"
61- stage="before-request-body"/>
62- -->
63- </bean-shell-rules >
64-
65- <!--
66- Set authorization rules by path. Types are: regex Operators for
67- must-match are: contains,equals,inList,exists
68- -->
69- <authorization-rules >
70- <restrict-source-ip type =" regex"
71- ip-regex=" (192\.168\.1\..*|127.0.0.1)" >/admin/.*</restrict-source-ip >
72- <must-match path =" ^/admin/.*" variable =" request.headers.x-roles"
73- operator=" contains" value =" admin" />
74- </authorization-rules >
75-
76-
77-
78- <!--
79- Set rules for incoming URLs.
80- -->
81- <url-rules >
82- <restrict-extension deny =" .jpg" />
83-
84- <restrict-method deny =" GET" path =" .*\.do$" />
85- <restrict-method allow =" ^(GET|POST|TRACE)$" />
86-
87- <enforce-https path =" /.*" >
88- <path-exception >/index.html</path-exception >
89- <path-exception >/index.jsp</path-exception >
90- <path-exception type =" regex" >/images/.*</path-exception >
91- <path-exception type =" regex" >/css/.*</path-exception >
92- <path-exception type =" regex" >/help/.*</path-exception >
93- </enforce-https >
94- </url-rules >
95-
96-
97-
98- <!--
99- Set rules for incoming headers and parameters.
100- -->
101- <header-rules >
102- <restrict-content-type deny =" .*multipart.*" />
103- <restrict-content-type allow =" text/plain" />
104- <restrict-content-type allow =" x-www-form-urlencoded" />
105- <restrict-user-agent deny =" .*GoogleBot.*" />
106- <restrict-user-agent allow =" .*" />
107- </header-rules >
108-
109-
110- <!--
111- Set virtual patches to match specific vulnerability patterns.
112- -->
113- <virtual-patches >
114- <virtual-patch id =" 1234" path =" /foo.jsp" variable =" request.parameters.bar"
115- pattern=" [0-9a-zA-Z]" message =" zomg attax" />
116- </virtual-patches >
117-
118-
119-
120- <!-- Set rules for outbound headers and data -->
121-
122- <outbound-rules >
123-
124- <add-header name =" FOO" value =" BAR" path =" /.*" >
125- <path-exception type =" regex" >/foobar/.*</path-exception >
126- </add-header >
127-
128- <add-http-only-flag >
129- <cookie name =" .*" />
130- </add-http-only-flag >
131-
132- <add-secure-flag >
133- <cookie name =" .*" />
134- </add-secure-flag >
135-
136- <dynamic-insertion pattern =" < /body> " >
137- <replacement ><![CDATA[ this is a test]]> </replacement >
138- </dynamic-insertion >
139-
140- <dynamic-insertion
141- pattern=" (< input.*)type\s+=\s+" +hidden" +(.*/> )" >
142- <replacement >\1\2</replacement >
143- </dynamic-insertion >
144-
145- <detect-content content-type =" .*text/.*" pattern =" .*2008.*" />
146-
147- </outbound-rules >
148-
1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+
3+ <!--
4+ This file defines a set of "web application firewall" rules that
5+ defend a web application against certain types of attacks. These rules
6+ are loaded and enforced by a filter that sits in front of a web
7+ application and has access to both request and response on both the
8+ way in and the way out.
9+ -->
10+
11+ <policy >
12+
13+
14+ <!--
15+ Setup some simple aliases to use elsewhere in the WAF policy. Alias
16+ types are: string (default), regex. String is a literal string, regex
17+ is a pattern.
18+ -->
19+ <aliases >
20+ <alias name =" INPUT_VALIDATION_ERROR" >/security/input.jsp</alias >
21+ <alias name =" ADMIN_PATH" type =" regex" >^/admin/.*</alias >
22+ </aliases >
23+
24+
25+
26+ <!--
27+ Set the overall WAF mode of operation. The mode can be either "block"
28+ or "log". "block" mode will send all errors to the web page defined in
29+ the error-handling configuration. "log" mode will not change HTTP
30+ requests at all, but will simply log errors.
31+ -->
32+ <settings >
33+ <mode >redirect</mode >
34+ <session-cookie-name >JSESSIONID</session-cookie-name >
35+ <error-handling >
36+ <default-redirect-page >/security/error.jsp</default-redirect-page >
37+ <block-status >403</block-status >
38+ </error-handling >
39+ </settings >
40+
41+
42+
43+ <!--
44+ Set authentication rules by path.
45+ -->
46+ <authentication-rules path =" /.*" key =" ESAPIUserSessionKey" >
47+ <path-exception >/</path-exception >
48+ <path-exception >/index.html</path-exception >
49+ <path-exception >/login.jsp</path-exception >
50+ <path-exception >/index.jsp</path-exception >
51+ <path-exception type =" regex" >/images/.*</path-exception >
52+ <path-exception type =" regex" >/css/.*</path-exception >
53+ <path-exception type =" regex" >/help/.*</path-exception >
54+ </authentication-rules >
55+
56+
57+ <bean-shell-rules >
58+ <!-- <bean-shell-script
59+ id="example1"
60+ file="waf-policies/bean-shell-rule.bsh"
61+ stage="before-request-body"/>
62+ -->
63+ </bean-shell-rules >
64+
65+ <!--
66+ Set authorization rules by path. Types are: regex Operators for
67+ must-match are: contains,equals,inList,exists
68+ -->
69+ <authorization-rules >
70+ <restrict-source-ip type =" regex"
71+ ip-regex=" (192\.168\.1\..*|127.0.0.1)" >/admin/.*</restrict-source-ip >
72+ <must-match path =" ^/admin/.*" variable =" request.headers.x-roles"
73+ operator=" contains" value =" admin" />
74+ </authorization-rules >
75+
76+
77+
78+ <!--
79+ Set rules for incoming URLs.
80+ -->
81+ <url-rules >
82+ <restrict-extension deny =" .jpg" />
83+
84+ <restrict-method deny =" GET" path =" .*\.do$" />
85+ <restrict-method allow =" ^(GET|POST|TRACE)$" />
86+
87+ <enforce-https path =" /.*" >
88+ <path-exception >/index.html</path-exception >
89+ <path-exception >/index.jsp</path-exception >
90+ <path-exception type =" regex" >/images/.*</path-exception >
91+ <path-exception type =" regex" >/css/.*</path-exception >
92+ <path-exception type =" regex" >/help/.*</path-exception >
93+ </enforce-https >
94+ </url-rules >
95+
96+
97+
98+ <!--
99+ Set rules for incoming headers and parameters.
100+ -->
101+ <header-rules >
102+ <restrict-content-type deny =" .*multipart.*" />
103+ <restrict-content-type allow =" text/plain" />
104+ <restrict-content-type allow =" x-www-form-urlencoded" />
105+ <restrict-user-agent deny =" .*GoogleBot.*" />
106+ <restrict-user-agent allow =" .*" />
107+ </header-rules >
108+
109+
110+ <!--
111+ Set virtual patches to match specific vulnerability patterns.
112+ -->
113+ <virtual-patches >
114+ <virtual-patch id =" 1234" path =" /foo.jsp" variable =" request.parameters.bar"
115+ pattern=" [0-9a-zA-Z]" message =" zomg attax" />
116+ </virtual-patches >
117+
118+
119+
120+ <!-- Set rules for outbound headers and data -->
121+
122+ <outbound-rules >
123+
124+ <add-header name =" FOO" value =" BAR" path =" /.*" >
125+ <path-exception type =" regex" >/foobar/.*</path-exception >
126+ </add-header >
127+
128+ <add-http-only-flag >
129+ <cookie name =" .*" />
130+ </add-http-only-flag >
131+
132+ <add-secure-flag >
133+ <cookie name =" .*" />
134+ </add-secure-flag >
135+
136+ <dynamic-insertion pattern =" < /body> " >
137+ <replacement ><![CDATA[ this is a test]]> </replacement >
138+ </dynamic-insertion >
139+
140+ <dynamic-insertion
141+ pattern=" (< input.*)type\s+=\s+" +hidden" +(.*/> )" >
142+ <replacement >\1\2</replacement >
143+ </dynamic-insertion >
144+
145+ <detect-content content-type =" .*text/.*" pattern =" .*2008.*" />
146+
147+ </outbound-rules >
148+
149149</policy >
0 commit comments