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

Commit ab241d5

Browse files
committed
SQLi: split 942510 into PL2 rule (backticks) and PL3 rule 942511 (ticks)
1 parent b3a6ccf commit ab241d5

File tree

3 files changed

+177
-68
lines changed

3 files changed

+177
-68
lines changed

rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf

Lines changed: 105 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -508,52 +508,6 @@ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAME
508508
setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
509509
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
510510

511-
#
512-
# -=[ Detect SQLi bypass: ticks and backticks ]=-
513-
#
514-
# Ticks and backticks can be used to bypass SQLi detection.
515-
#
516-
# Example:
517-
# GET http://localhost/test.php?id=9999%20or+{`if`(2=(select+2+from+wp_users+where+user_login='admin'))}
518-
#
519-
# The minimum text between the ticks or backticks must be 2 (if, for example) and a maximum of 29.
520-
# 29 is a compromise: The lower this number (29), the lower the probability of FP and the higher the probability of false negatives.
521-
# In tests we got a minimum number of FP with {2,29}.
522-
#
523-
# Base64 encoding detection:
524-
# (?:[A-Za-z0-9+/]{4})+ #match any number of 4-letter blocks of the base64 char set
525-
# (?:[A-Za-z0-9+/]{2}== #match 2-letter block of the base64 char set followed by "==", together forming a 4-letter block
526-
# | # or
527-
# [A-Za-z0-9+/]{3}= #match 3-letter block of the base64 char set followed by "=", together forming a 4-letter block
528-
# )?
529-
#
530-
# The minimal string that triggers this regexp is: 'if' or ` `
531-
#
532-
# The rule 942510 is related to 942110 which catches a single ' or `
533-
#
534-
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?:(['`])((?:[\w\s=_\-+{}()<@]){2,29}|(?:[A-Za-z0-9+\/]{4})+(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)\1)" \
535-
"id:942510,\
536-
phase:2,\
537-
block,\
538-
capture,\
539-
t:none,t:urlDecodeUni,\
540-
msg:'SQLi bypass attempt by ticks or backticks detected.',\
541-
logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
542-
tag:'application-multi',\
543-
tag:'language-multi',\
544-
tag:'platform-multi',\
545-
tag:'attack-sqli',\
546-
tag:'OWASP_CRS',\
547-
tag:'OWASP_CRS/WEB_ATTACK/SQL_INJECTION',\
548-
tag:'WASCTC/WASC-19',\
549-
tag:'OWASP_TOP_10/A1',\
550-
tag:'OWASP_AppSensor/CIE1',\
551-
tag:'PCI/6.5.2',\
552-
ver:'OWASP_CRS/3.2.0',\
553-
severity:'CRITICAL',\
554-
setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
555-
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
556-
557511

558512
SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 2" "id:942013,phase:1,pass,nolog,skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
559513
SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 2" "id:942014,phase:2,pass,nolog,skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
@@ -1375,6 +1329,59 @@ SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|!REQUEST_COOKIES:/_pk_ref/|REQU
13751329
setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
13761330
setvar:'tx.anomaly_score_pl2=+%{tx.critical_anomaly_score}'"
13771331

1332+
1333+
#
1334+
# -=[ Detect SQLi bypass: backticks ]=-
1335+
#
1336+
# Quotes and backticks can be used to bypass SQLi detection.
1337+
#
1338+
# Example:
1339+
# GET http://localhost/test.php?id=9999%20or+{`if`(2=(select+2+from+wp_users+where+user_login='admin'))}
1340+
#
1341+
# The minimum text between the ticks or backticks must be 2 (if, for example) and a maximum of 29.
1342+
# 29 is a compromise: The lower this number (29), the lower the probability of FP and the higher the probability of false negatives.
1343+
# In tests we got a minimum number of FP with {2,29}.
1344+
#
1345+
# Base64 encoding detection:
1346+
# (?:[A-Za-z0-9+/]{4})+ #match any number of 4-letter blocks of the base64 char set
1347+
# (?:[A-Za-z0-9+/]{2}== #match 2-letter block of the base64 char set followed by "==", together forming a 4-letter block
1348+
# | # or
1349+
# [A-Za-z0-9+/]{3}= #match 3-letter block of the base64 char set followed by "=", together forming a 4-letter block
1350+
# )?
1351+
#
1352+
# The minimal string that triggers this regexp is: `if`
1353+
#
1354+
# The rule 942510 is related to 942110 which catches a single ' or `
1355+
#
1356+
# The rule 942511 is similar to this rule, but triggers on normal quotes
1357+
# ('if'). That rule runs in paranoia level 3 or higher since it is prone to
1358+
# false positives in natural text.
1359+
#
1360+
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?:`((?:[\w\s=_\-+{}()<@]){2,29}|(?:[A-Za-z0-9+\/]{4})+(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)`)" \
1361+
"id:942510,\
1362+
phase:2,\
1363+
block,\
1364+
capture,\
1365+
t:none,t:urlDecodeUni,\
1366+
msg:'SQLi bypass attempt by ticks or backticks detected.',\
1367+
logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1368+
tag:'application-multi',\
1369+
tag:'language-multi',\
1370+
tag:'platform-multi',\
1371+
tag:'attack-sqli',\
1372+
tag:'OWASP_CRS',\
1373+
tag:'OWASP_CRS/WEB_ATTACK/SQL_INJECTION',\
1374+
tag:'WASCTC/WASC-19',\
1375+
tag:'OWASP_TOP_10/A1',\
1376+
tag:'OWASP_AppSensor/CIE1',\
1377+
tag:'PCI/6.5.2',\
1378+
tag:'paranoia-level/2',\
1379+
ver:'OWASP_CRS/3.2.0',\
1380+
severity:'CRITICAL',\
1381+
setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1382+
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
1383+
1384+
13781385
SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 3" "id:942015,phase:1,pass,nolog,skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
13791386
SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 3" "id:942016,phase:2,pass,nolog,skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
13801387
#
@@ -1589,6 +1596,58 @@ SecRule REQUEST_BASENAME "@detectSQLi" \
15891596
setvar:'tx.anomaly_score_pl3=+%{tx.critical_anomaly_score}'"
15901597

15911598

1599+
#
1600+
# -=[ Detect SQLi bypass: quotes ]=-
1601+
#
1602+
# Quotes and backticks can be used to bypass SQLi detection.
1603+
#
1604+
# Example:
1605+
# GET http://localhost/test.php?id=9999%20or+{`if`(2=(select+2+from+wp_users+where+user_login='admin'))}
1606+
#
1607+
# The minimum text between the ticks or backticks must be 2 (if, for example) and a maximum of 29.
1608+
# 29 is a compromise: The lower this number (29), the lower the probability of FP and the higher the probability of false negatives.
1609+
# In tests we got a minimum number of FP with {2,29}.
1610+
#
1611+
# Base64 encoding detection:
1612+
# (?:[A-Za-z0-9+/]{4})+ #match any number of 4-letter blocks of the base64 char set
1613+
# (?:[A-Za-z0-9+/]{2}== #match 2-letter block of the base64 char set followed by "==", together forming a 4-letter block
1614+
# | # or
1615+
# [A-Za-z0-9+/]{3}= #match 3-letter block of the base64 char set followed by "=", together forming a 4-letter block
1616+
# )?
1617+
#
1618+
# The minimal string that triggers this regexp is: 'if'
1619+
#
1620+
# The rule 942511 is related to 942110 which catches a single ' or `
1621+
#
1622+
# The rule 942510 is similar to this rule, but triggers on backticks
1623+
# (`if'). That rule runs in paranoia level 2 or higher since the risk of
1624+
# false positives in natural text is still present but lower than this
1625+
# rule.
1626+
#
1627+
SecRule REQUEST_COOKIES|!REQUEST_COOKIES:/__utm/|REQUEST_COOKIES_NAMES|ARGS_NAMES|ARGS|XML:/* "@rx (?:'((?:[\w\s=_\-+{}()<@]){2,29}|(?:[A-Za-z0-9+\/]{4})+(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)')" \
1628+
"id:942511,\
1629+
phase:2,\
1630+
block,\
1631+
capture,\
1632+
t:none,t:urlDecodeUni,\
1633+
msg:'SQLi bypass attempt by ticks detected.',\
1634+
logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',\
1635+
tag:'application-multi',\
1636+
tag:'language-multi',\
1637+
tag:'platform-multi',\
1638+
tag:'attack-sqli',\
1639+
tag:'OWASP_CRS',\
1640+
tag:'OWASP_CRS/WEB_ATTACK/SQL_INJECTION',\
1641+
tag:'WASCTC/WASC-19',\
1642+
tag:'OWASP_TOP_10/A1',\
1643+
tag:'OWASP_AppSensor/CIE1',\
1644+
tag:'PCI/6.5.2',\
1645+
tag:'paranoia-level/3',\
1646+
ver:'OWASP_CRS/3.2.0',\
1647+
severity:'CRITICAL',\
1648+
setvar:'tx.sql_injection_score=+%{tx.critical_anomaly_score}',\
1649+
setvar:'tx.anomaly_score_pl1=+%{tx.critical_anomaly_score}'"
1650+
15921651
SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 4" "id:942017,phase:1,pass,nolog,skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
15931652
SecRule TX:EXECUTING_PARANOIA_LEVEL "@lt 4" "id:942018,phase:2,pass,nolog,skipAfter:END-REQUEST-942-APPLICATION-ATTACK-SQLI"
15941653
#
Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
---
2-
meta:
3-
author: "Franziska Buehler"
4-
description: None
5-
enabled: true
6-
name: 942510.yaml
7-
tests:
8-
-
9-
test_title: 942510-1
10-
desc: "SQLi bypass detected: ticks or backticks"
2+
meta:
3+
author: "Franziska Buehler"
4+
description: None
5+
enabled: true
6+
name: 942510.yaml
7+
tests:
8+
- test_title: 942510-1
9+
desc: "SQLi bypass detected: backticks"
1110
stages:
12-
-
13-
stage:
14-
input:
15-
dest_addr: 127.0.0.1
16-
headers:
17-
User-Agent: "ModSecurity CRS 3 Tests"
18-
Host: localhost
19-
method: GET
20-
port: 80
21-
uri: "/?'bla'"
22-
version: HTTP/1.0
23-
output:
24-
log_contains: id "942510"
11+
- stage:
12+
input:
13+
dest_addr: 127.0.0.1
14+
headers:
15+
User-Agent: "ModSecurity CRS 3 Tests"
16+
Host: localhost
17+
method: GET
18+
port: 80
19+
uri: "/?`bla`"
20+
version: HTTP/1.0
21+
output:
22+
log_contains: id "942510"
23+
- test_title: 942510-2
24+
desc: "SQLi bypass detected: backticks"
25+
stages:
26+
- stage:
27+
input:
28+
dest_addr: 127.0.0.1
29+
headers:
30+
User-Agent: "ModSecurity CRS 3 Tests"
31+
Host: localhost
32+
method: GET
33+
port: 80
34+
uri: "/?'bla'"
35+
version: HTTP/1.0
36+
output:
37+
no_log_contains: id "942510"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
meta:
3+
author: "Walter Hop"
4+
description: None
5+
enabled: true
6+
name: 942511.yaml
7+
tests:
8+
- test_title: 942511-1
9+
desc: "SQLi bypass detected: quotes"
10+
stages:
11+
- stage:
12+
input:
13+
dest_addr: 127.0.0.1
14+
headers:
15+
User-Agent: "ModSecurity CRS 3 Tests"
16+
Host: localhost
17+
method: GET
18+
port: 80
19+
uri: "/?`bla`"
20+
version: HTTP/1.0
21+
output:
22+
no_log_contains: id "942511"
23+
- test_title: 942511-2
24+
desc: "SQLi bypass detected: quotes"
25+
stages:
26+
- stage:
27+
input:
28+
dest_addr: 127.0.0.1
29+
headers:
30+
User-Agent: "ModSecurity CRS 3 Tests"
31+
Host: localhost
32+
method: GET
33+
port: 80
34+
uri: "/?'bla'"
35+
version: HTTP/1.0
36+
output:
37+
log_contains: id "942511"

0 commit comments

Comments
 (0)