Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit 4f150d3

Browse files
authored
Merge pull request #735 from dune73/crs-pull-fixing-ddos
Fixing bug in 912160 (dos_burst_counter jumping from 0 to 2)
2 parents 811c719 + 316f415 commit 4f150d3

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

rules/REQUEST-912-DOS-PROTECTION.conf

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,16 @@ SecRule REQUEST_BASENAME ".*?(\.[a-z0-9]{1,10})?$" \
177177
#
178178
# Check DOS Counter
179179
# If the request count is greater than or equal to user settings,
180-
# we set the burst counter.
180+
# we raise the burst counter. This happens via two separate rules:
181+
# - 912160: raise from 0 to 1
182+
# - 912161: raise from 1 to 2
181183
#
182-
SecRule IP:DOS_COUNTER "@gt %{tx.dos_counter_threshold}" \
184+
# This approach with two rules avoids raising the burst counter
185+
# from 0 to 2 via two concurrent requests. We do not raise the
186+
# burst counter beyond 2.
187+
#
188+
#
189+
SecRule IP:DOS_COUNTER "@ge %{tx.dos_counter_threshold}" \
183190
"phase:5,\
184191
id:912160,\
185192
t:none,\
@@ -189,9 +196,28 @@ SecRule IP:DOS_COUNTER "@gt %{tx.dos_counter_threshold}" \
189196
tag:'language-multi',\
190197
tag:'platform-multi',\
191198
tag:'attack-dos',\
192-
setvar:ip.dos_burst_counter=+1,\
193-
expirevar:ip.dos_burst_counter=%{tx.dos_burst_time_slice},\
194-
setvar:!ip.dos_counter"
199+
chain"
200+
SecRule &IP:DOS_BURST_COUNTER "@eq 0" \
201+
"setvar:ip.dos_burst_counter=1,\
202+
expirevar:ip.dos_burst_counter=%{tx.dos_burst_time_slice},\
203+
setvar:!ip.dos_counter"
204+
205+
206+
SecRule IP:DOS_COUNTER "@ge %{tx.dos_counter_threshold}" \
207+
"phase:5,\
208+
id:912161,\
209+
t:none,\
210+
nolog,\
211+
pass,\
212+
tag:'application-multi',\
213+
tag:'language-multi',\
214+
tag:'platform-multi',\
215+
tag:'attack-dos',\
216+
chain"
217+
SecRule &IP:DOS_BURST_COUNTER "@ge 1" \
218+
"setvar:ip.dos_burst_counter=2,\
219+
expirevar:ip.dos_burst_counter=%{tx.dos_burst_time_slice},\
220+
setvar:!ip.dos_counter"
195221

196222

197223
#

0 commit comments

Comments
 (0)