-
Notifications
You must be signed in to change notification settings - Fork 2
/
owasp-top-10-aws-waf-conditions.yml
402 lines (387 loc) · 11.7 KB
/
owasp-top-10-aws-waf-conditions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
---
waf_conditions:
- example_condition:
name: my_sql_condition
filters:
- field_to_match: query_string
transformation: url_decode
state: present
type: sql
## 1.
## OWASP Top 10 A1
## Mitigate SQL Injection Attacks
## Matches attempted SQLi patterns in the URI, QUERY_STRING, BODY, COOKIES
- sql_inj:
name: fix_sql_injection
filters:
- field_to_match: uri
transformation: url_decode
- field_to_match: uri
transformation: html_entity_decode
- field_to_match: query_string
transformation: url_decode
- field_to_match: query_string
transformation: html_entity_decode
- field_to_match: body
transformation: url_decode
- field_to_match: body
transformation: html_entity_decode
- field_to_match: header
header: cookie
transformation: url_decode
- field_to_match: header
header: cookie
transformation: html_entity_decode
state: present
type: sql
## 2.
## OWASP Top 10 A2
## Blacklist bad/hijacked JWT tokens or session IDs
## Matches the specific values in the cookie or Authorization header
## for JWT it is sufficient to check the signature
- fix_auth_token_string:
name: fix_auth_token_string
filters:
- field_to_match: header
header: cookie
position: CONTAINS
target_string: example-session-id
transformation: url_decode
- field_to_match: header
header: authorization
position: ENDS_WITH
target_string: .TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
transformation: url_decode
type: byte
## 3.
## OWASP Top 10 A3
## Mitigate Cross Site Scripting Attacks
## Matches attempted XSS patterns in the URI, QUERY_STRING, BODY, COOKIES
- fix_xss_scripting:
name: fix_xss_scripting
filters:
- field_to_match: uri
transformation: url_decode
- field_to_match: uri
transformation: html_entity_decode
- field_to_match: query_string
transformation: url_decode
- field_to_match: query_string
transformation: html_entity_decode
- field_to_match: body
transformation: url_decode
- field_to_match: body
transformation: html_entity_decode
- field_to_match: header
header: cookie
transformation: url_decode
- field_to_match: header
header: cookie
transformation: html_entity_decode
type: xss
## 4.
## OWASP Top 10 A4
## Path Traversal, LFI, RFI
## Matches request patterns designed to traverse filesystem paths, and include
## local or remote files
- fix_path_traversal:
name: fix_path_traversal
filters:
- field_to_match: uri
position: CONTAINS
target_string: '../'
transformation: url_decode
- field_to_match: uri
position: CONTAINS
target_string: '../'
transformation: html_entity_decode
- field_to_match: query_string
position: CONTAINS
target_string: '../'
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: '../'
transformation: html_entity_decode
- field_to_match: uri
position: CONTAINS
target_string: '://'
transformation: url_decode
- field_to_match: uri
position: CONTAINS
target_string: '://'
transformation: html_entity_decode
- field_to_match: query_string
position: CONTAINS
target_string: '://'
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: '://'
transformation: html_entity_decode
type: byte
## 5.
## OWASP Top 10 A4
## Privileged Module Access Restrictions
## Restrict access to the admin interface to known source IPs only
## Matches the URI prefix, when the remote IP isn't in the whitelist
- fix_privileged_module_access:
name: fix_privileged_module_access
filters:
- field_to_match: uri
position: STARTS_WITH
target_string: "{{ admin_url_prefix }}"
transformation: url_decode
type: byte
- restrict_ip_access_admin:
name: restrict_ip_access_admin
filters:
- ip_address: "10.0.0.0/8"
- ip_address: "192.168.0.0/24"
type: ip
## 6.
## OWASP Top 10 A5
## PHP Specific Security Misconfigurations
## Matches request patterns designed to exploit insecure PHP/CGI configuration
- fix_common_php_sec_misconfig:
name: fix_common_php_sec_misconfig
filters:
- field_to_match: query_string
position: CONTAINS
target_string: '_SERVER['
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: '_ENV['
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: 'auto_prepend_file='
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: 'auto_append_file='
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: 'allow_url_include='
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: 'disable_functions='
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: 'open_basedir='
transformation: url_decode
- field_to_match: query_string
position: CONTAINS
target_string: 'safe_mode='
transformation: url_decode
type: byte
- fix_php_insecure_uri_stringset:
name: fix_php_insecure_uri_stringset
filters:
- field_to_match: uri
position: ENDS_WITH
target_string: php
transformation: url_decode
- field_to_match: uri
position: ENDS_WITH
target_string: /
transformation: url_decode
type: byte
## 7.
## OWASP Top 10 A7
## Mitigate abnormal requests via size restrictions
## Enforce consistent request hygene, limit size of key elements
- fix_waf_size_restriction_set:
name: fix_waf_size_restriction_set
filters:
- field_to_match: uri
transformation: none
comparison: GT
size: "{{ max_expected_uri_size }}"
- field_to_match: query_string
transformation: none
comparison: GT
size: "{{ max_expected_query_string_size }}"
- field_to_match: body
transformation: none
comparison: GT
size: "{{ max_expected_body_size }}"
- field_to_match: header
header: cookie
transformation: none
comparison: GT
size: "{{ max_expected_cookie_size }}"
type: size
## 8.
## OWASP Top 10 A8
## CSRF token enforcement example
## Enforce the presence of CSRF token in request header
- fix_waf_csrf_method_string:
name: fix_waf_csrf_method_string
filters:
- field_to_match: method
position: EXACTLY
target_string: post
transformation: lowercase
type: byte
- fix_waf_csrf_token_size_constraint:
name: fix_waf_csrf_token_size_constraint
filters:
- field_to_match: header
header: "{{ csrf_expected_header }}"
transformation: none
comparison: EQ
size: "{{ csrf_expected_size }}"
type: size
## 9.
## OWASP Top 10 A9
## Server-side includes & libraries in webroot
## Matches request patterns for webroot objects that shouldn't be directly accessible
- fix_waf_server_side_include_string:
name: fix_waf_server_side_include_string
filters:
- field_to_match: uri
position: STARTS_WITH
target_string: "{{ includes_prefix }}"
transformation: url_decode
- field_to_match: uri
position: ENDS_WITH
target_string: .cfg
transformation: lowercase
- field_to_match: uri
position: ENDS_WITH
target_string: .conf
transformation: lowercase
- field_to_match: uri
position: ENDS_WITH
target_string: .config
transformation: lowercase
- field_to_match: uri
position: ENDS_WITH
target_string: .ini
transformation: lowercase
- field_to_match: uri
position: ENDS_WITH
target_string: .log
transformation: lowercase
- field_to_match: uri
position: ENDS_WITH
target_string: .bak
transformation: lowercase
- field_to_match: uri
position: ENDS_WITH
target_string: .backup
transformation: lowercase
type: byte
## 10.
## Generic
## IP Blacklist
## Matches IP addresses that should not be allowed to access content
- waf_blacklist_ip_set:
name: waf_blacklist_ip_set
filters:
- ip_address: 10.0.0.0/8
- ip_address: 192.168.0.0/16
- ip_address: 169.254.0.0/16
- ip_address: 172.16.0.0/16
- ip_address: 127.0.0.1/32
type: ip
# Create a rule for each of the owasp top 10 grouping together each condition
# Despite the rules & conditions having the potential to be shared across
# deployments for now we are not going to do that. So for now all conditions
# rules are prefixed with {{ application_name }}_{{ env_target }}
waf_rules:
- example_1_rule:
name: example_1_rule
conditions:
- name: fenics_dev_my_sql_condition_regional
type: sql
negated: no
state: present
- example_2_rule:
name: example_2_rule
conditions:
- name: fenics_dev_my_sql_condition_regional
type: sql
negated: no
state: present
- example_3_rule:
name: example_3_rule
conditions:
- name: fenics_dev_my_sql_condition_regional
type: sql
negated: no
state: present
- rule_owasp_1_fix_sql_injection:
name: rule_owasp_1_fix_sql_injection
conditions:
- name: fix_sql_injection
type: sql
negated: no
- rule_owasp_2_fix_auth_token_string:
name: rule_owasp_2_fix_auth_token_string
conditions:
- name: fix_auth_token_string
type: byte
negated: no
- rule_owasp_3_fix_xss_scripting:
name: rule_owasp_3_fix_xss_scripting
conditions:
- name: fix_xss_scripting
type: xss
negated: no
- rule_owasp_4_fix_path_traversal:
name: rule_owasp_4_fix_path_traversal
conditions:
- name: fix_path_traversal
type: byte
negated: no
- rule_owasp_5_fix_path_traversal:
name: rule_owasp_5_fix_privileged_module_access
conditions:
- name: fix_privileged_module_access
type: byte
negated: no
- name: restrict_ip_access_admin
type: ip
negated: no
- rule_owasp_6_fix_common_php_sec_misconfig:
name: rule_owasp_6_fix_common_php_sec_misconfig
conditions:
- name: fix_common_php_sec_misconfig
type: byte
negated: no
- name: fix_php_insecure_uri_stringset
type: byte
negated: no
- rule_owasp_7_fix_waf_size_restriction_set:
name: rule_owasp_7_fix_waf_size_restriction_set
conditions:
- name: fix_waf_size_restriction_set
type: size
negated: no
- rule_owasp_8_fix_waf_csrf_method_string:
name: rule_owasp_8_fix_waf_csrf_method_string
conditions:
- name: fix_waf_csrf_method_string
type: byte
negated: no
- name: fix_waf_csrf_token_size_constraint
type: size
negated: no
- rule_owasp_9_fix_waf_server_side_include_string:
name: rule_owasp_9_fix_waf_server_side_include_string
conditions:
- name: fix_waf_server_side_include_string
type: byte
negated: no
- rule_owasp_10_waf_blacklist_ip_set:
name: rule_owasp_10_waf_blacklist_ip_set
conditions:
- name: waf_blacklist_ip_set
type: ip
negated: no