Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: accidental firewall disability prevention #3650

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rules/REQUEST-901-INITIALIZATION.conf
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ SecAction \
nolog,\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.0.1-dev',\
setvar:'tx.inbound_early_blocking_evaluated=0',\
setvar:'tx.inbound_blocking_evaluated=0',\
setvar:'tx.outbound_early_blocking_evaluated=0',\
setvar:'tx.outbound_blocking_evaluated=0',\
setvar:'tx.blocking_inbound_anomaly_score=0',\
setvar:'tx.detection_inbound_anomaly_score=0',\
setvar:'tx.inbound_anomaly_score_pl1=0',\
Expand Down
14 changes: 10 additions & 4 deletions rules/REQUEST-949-BLOCKING-EVALUATION.conf
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ SecMarker "BEGIN-REQUEST-BLOCKING-EVAL"
#

# if early blocking is active, check threshold in phase 1
SecRule TX:BLOCKING_INBOUND_ANOMALY_SCORE "@ge %{tx.inbound_anomaly_score_threshold}" \
SecAction \
"id:949111,\
phase:1,\
deny,\
Expand All @@ -218,19 +218,25 @@ SecRule TX:BLOCKING_INBOUND_ANOMALY_SCORE "@ge %{tx.inbound_anomaly_score_thresh
tag:'anomaly-evaluation',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.0.1-dev',\
setvar:'tx.inbound_early_blocking_evaluated=1',\
chain"
SecRule TX:EARLY_BLOCKING "@eq 1"
SecRule TX:BLOCKING_INBOUND_ANOMALY_SCORE "@ge %{tx.inbound_anomaly_score_threshold}" \
"chain"
SecRule TX:EARLY_BLOCKING "@eq 1" "setvar:'tx.inbound_blocking_evaluated=1',setvar:'tx.outbound_early_blocking_evaluated=1',setvar:'tx.outbound_blocking_evaluated=1'"

# always check threshold in phase 2
SecRule TX:BLOCKING_INBOUND_ANOMALY_SCORE "@ge %{tx.inbound_anomaly_score_threshold}" \
SecAction \
"id:949110,\
phase:2,\
deny,\
t:none,\
msg:'Inbound Anomaly Score Exceeded (Total Score: %{TX.BLOCKING_INBOUND_ANOMALY_SCORE})',\
tag:'anomaly-evaluation',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.0.1-dev'"
ver:'OWASP_CRS/4.0.1-dev',\
setvar:'tx.inbound_blocking_evaluated=1',\
chain"
SecRule TX:BLOCKING_INBOUND_ANOMALY_SCORE "@ge %{tx.inbound_anomaly_score_threshold}" "setvar:'tx.outbound_early_blocking_evaluated=1',setvar:'tx.outbound_blocking_evaluated=1'"
dune73 marked this conversation as resolved.
Show resolved Hide resolved

SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:949011,phase:1,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.0.1-dev',skipAfter:END-REQUEST-949-BLOCKING-EVALUATION"
SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:949012,phase:2,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.0.1-dev',skipAfter:END-REQUEST-949-BLOCKING-EVALUATION"
Expand Down
14 changes: 10 additions & 4 deletions rules/RESPONSE-959-BLOCKING-EVALUATION.conf
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ SecRule TX:DETECTION_PARANOIA_LEVEL "@ge 4" \
#

# if early blocking is active, check threshold in phase 3
SecRule TX:BLOCKING_OUTBOUND_ANOMALY_SCORE "@ge %{tx.outbound_anomaly_score_threshold}" \
SecAction \
"id:959101,\
phase:3,\
deny,\
Expand All @@ -228,19 +228,25 @@ SecRule TX:BLOCKING_OUTBOUND_ANOMALY_SCORE "@ge %{tx.outbound_anomaly_score_thre
tag:'anomaly-evaluation',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.0.1-dev',\
setvar:'tx.outbound_early_blocking_evaluated=1',\
chain"
SecRule TX:EARLY_BLOCKING "@eq 1"
SecRule TX:BLOCKING_OUTBOUND_ANOMALY_SCORE "@ge %{tx.outbound_anomaly_score_threshold}" \
"chain"
SecRule TX:EARLY_BLOCKING "@eq 1" "setvar:'tx.outbound_blocking_evaluated=1'"

# always check threshold in phase 4
SecRule TX:BLOCKING_OUTBOUND_ANOMALY_SCORE "@ge %{tx.outbound_anomaly_score_threshold}" \
SecAction \
"id:959100,\
phase:4,\
deny,\
t:none,\
msg:'Outbound Anomaly Score Exceeded (Total Score: %{tx.blocking_outbound_anomaly_score})',\
tag:'anomaly-evaluation',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.0.1-dev'"
ver:'OWASP_CRS/4.0.1-dev',\
setvar:'tx.outbound_blocking_evaluated=1',\
chain"
SecRule TX:BLOCKING_OUTBOUND_ANOMALY_SCORE "@ge %{tx.outbound_anomaly_score_threshold}"

SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:959011,phase:3,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.0.1-dev',skipAfter:END-RESPONSE-959-BLOCKING-EVALUATION"
SecRule TX:DETECTION_PARANOIA_LEVEL "@lt 1" "id:959012,phase:4,pass,nolog,tag:'OWASP_CRS',ver:'OWASP_CRS/4.0.1-dev',skipAfter:END-RESPONSE-959-BLOCKING-EVALUATION"
Expand Down
9 changes: 9 additions & 0 deletions rules/RESPONSE-980-CORRELATION.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
# -= Paranoia Level 0 (empty) =- (apply unconditionally)
#

SecRule TX:inbound_early_blocking_evaluated|TX:inbound_blocking_evaluated|TX:outbound_early_blocking_evaluated|TX:outbound_blocking_evaluated "@eq 0" \
"id:980098,\
phase:5,\
pass,\
t:none,\
msg:'ATTENTION, FIREWALL IS DISABLED!!! At least one of the blocking evaluation rules was not executed (Inbound early blocking evaluated: %{tx.inbound_early_blocking_evaluated}, inbound blocking evaluated: %{tx.inbound_blocking_evaluated}, outbound early blocking evaluated: %{tx.outbound_early_blocking_evaluated}, outbound blocking evaluated: %{tx.outbound_blocking_evaluated})',\
tag:'OWASP_CRS',\
ver:'OWASP_CRS/4.0.1-dev'"

# Combine inbound and outbound scores
SecAction \
"id:980099,\
Expand Down