Skip to content

Commit 92740fd

Browse files
committed
ascanrules: SQLi MsSQL rename scan rule (all timing based)
Signed-off-by: kingthorin <[email protected]>
1 parent dc2e143 commit 92740fd

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

addOns/ascanrules/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77
### Changed
88
- Maintenance changes.
99
- Depends on an updated version of the Common Library add-on.
10+
- The SQL Injection - MsSQL scan rule and alerts have been renamed to clarify that they're timing based (Issue 7341).
1011

1112
### Added
1213
- Rules (as applicable) have been tagged in relation to HIPAA and PCI DSS.
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
import org.zaproxy.zap.model.TechSet;
4545

4646
/**
47-
* The SqlInjectionMsSqlScanRule identifies MsSQL specific SQL Injection vulnerabilities using MsSQL
48-
* specific syntax. If it doesn't use MsSQL specific syntax, it belongs in the generic SQLInjection
49-
* class! Note the ordering of checks, for efficiency is : 1) Error based (N/A) 2) Boolean Based
50-
* (N/A - uses standard syntax) 3) UNION based (N/A - uses standard syntax) 4) Stacked (N/A - uses
51-
* standard syntax) 5) Blind/Time Based (Yes - uses specific syntax)
47+
* The SqlInjectionMsSqlTimingScanRule identifies MsSQL specific SQL Injection vulnerabilities using
48+
* MsSQL specific syntax. If it doesn't use MsSQL specific syntax, it belongs in the generic
49+
* SQLInjection class! Note the ordering of checks, for efficiency is : 1) Error based (N/A) 2)
50+
* Boolean Based (N/A - uses standard syntax) 3) UNION based (N/A - uses standard syntax) 4) Stacked
51+
* (N/A - uses standard syntax) 5) Blind/Time Based (Yes - uses specific syntax)
5252
*
5353
* <p>See the following for some great MySQL specific tricks which could be integrated here
5454
* http://www.websec.ca/kb/sql_injection#MSSQL_Stacked_Queries
5555
* http://pentestmonkey.net/cheat-sheet/sql-injection/mssql-sql-injection-cheat-sheet
5656
*/
57-
public class SqlInjectionMsSqlScanRule extends AbstractAppParamPlugin
57+
public class SqlInjectionMsSqlTimingScanRule extends AbstractAppParamPlugin
5858
implements CommonActiveScanRuleInfo {
5959

6060
/** MSSQL one-line comment */
@@ -134,7 +134,8 @@ public class SqlInjectionMsSqlScanRule extends AbstractAppParamPlugin
134134
private static final double TIME_SLOPE_ERROR_RANGE = 0.30;
135135

136136
/** for logging. */
137-
private static final Logger LOGGER = LogManager.getLogger(SqlInjectionMsSqlScanRule.class);
137+
private static final Logger LOGGER =
138+
LogManager.getLogger(SqlInjectionMsSqlTimingScanRule.class);
138139

139140
private static final Map<String, String> ALERT_TAGS;
140141

@@ -146,7 +147,8 @@ public class SqlInjectionMsSqlScanRule extends AbstractAppParamPlugin
146147
CommonAlertTag.OWASP_2017_A01_INJECTION,
147148
CommonAlertTag.WSTG_V42_INPV_05_SQLI,
148149
CommonAlertTag.HIPAA,
149-
CommonAlertTag.PCI_DSS));
150+
CommonAlertTag.PCI_DSS,
151+
CommonAlertTag.TEST_TIMING));
150152
alertTags.put(PolicyTag.DEV_FULL.getTag(), "");
151153
alertTags.put(PolicyTag.QA_STD.getTag(), "");
152154
alertTags.put(PolicyTag.QA_FULL.getTag(), "");

addOns/ascanrules/src/main/javahelp/org/zaproxy/zap/extension/ascanrules/resources/help/contents/ascanrules.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ <H2 id="id-40020">SQL Injection - Hypersonic (Time Based)</H2>
365365
<br>
366366
Alert ID: <a href="https://www.zaproxy.org/docs/alerts/40020/">40020</a>.
367367

368-
<H2 id="id-40027">SQL Injection - MsSQL</H2>
368+
<H2 id="id-40027">SQL Injection - MsSQL (Time Based)</H2>
369369
This active scan rule attempts to inject MsSQL specific sleep commands into parameter values and analyzes the server's response time to see if the sleep is effectively executed on the server (indicating a successful SQL injection attack).
370370
<p>
371371
Latest code: <a href="https://github.com/zaproxy/zap-extensions/blob/main/addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/SqlInjectionMsSqlScanRule.java">SqlInjectionMsSqlScanRule.java</a>

addOns/ascanrules/src/main/resources/org/zaproxy/zap/extension/ascanrules/resources/Messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ ascanrules.sqlinjection.authbypass.name = SQL Injection - Authentication Bypass
182182
ascanrules.sqlinjection.desc = SQL injection may be possible.
183183
ascanrules.sqlinjection.hypersonic.name = SQL Injection - Hypersonic SQL
184184
ascanrules.sqlinjection.mssql.alert.timebased.extrainfo = The query time is controllable using parameter value [{0}], which caused the request to take [{1}] milliseconds, when the original unmodified query with value [{2}] took [{3}] milliseconds.
185-
ascanrules.sqlinjection.mssql.name = SQL Injection - MsSQL
185+
ascanrules.sqlinjection.mssql.name = SQL Injection - MsSQL (Time Based)
186186
ascanrules.sqlinjection.mysql.name = SQL Injection - MySQL
187187
ascanrules.sqlinjection.name = SQL Injection
188188
ascanrules.sqlinjection.oracle.name = SQL Injection - Oracle
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
import org.zaproxy.zap.model.TechSet;
3939
import org.zaproxy.zap.testutils.NanoServerHandler;
4040

41-
/** Unit test for {@link SqlInjectionMsSqlScanRule}. */
42-
class SqlInjectionMsSqlScanRuleUnitTest extends ActiveScannerTest<SqlInjectionMsSqlScanRule> {
41+
/** Unit test for {@link SqlInjectionMsSqlTimingScanRule}. */
42+
class SqlInjectionMsSqlTimingScanRuleUnitTest
43+
extends ActiveScannerTest<SqlInjectionMsSqlTimingScanRule> {
4344

4445
@Override
45-
protected SqlInjectionMsSqlScanRule createScanner() {
46-
return new SqlInjectionMsSqlScanRule();
46+
protected SqlInjectionMsSqlTimingScanRule createScanner() {
47+
return new SqlInjectionMsSqlTimingScanRule();
4748
}
4849

4950
@Test
@@ -150,7 +151,7 @@ void shouldReturnExpectedMappings() {
150151
// Then
151152
assertThat(cwe, is(equalTo(89)));
152153
assertThat(wasc, is(equalTo(19)));
153-
assertThat(tags.size(), is(equalTo(10)));
154+
assertThat(tags.size(), is(equalTo(11)));
154155
assertThat(
155156
tags.containsKey(CommonAlertTag.OWASP_2021_A03_INJECTION.getTag()),
156157
is(equalTo(true)));
@@ -161,6 +162,7 @@ void shouldReturnExpectedMappings() {
161162
tags.containsKey(CommonAlertTag.WSTG_V42_INPV_05_SQLI.getTag()), is(equalTo(true)));
162163
assertThat(tags.containsKey(CommonAlertTag.HIPAA.getTag()), is(equalTo(true)));
163164
assertThat(tags.containsKey(CommonAlertTag.PCI_DSS.getTag()), is(equalTo(true)));
165+
assertThat(tags.containsKey(CommonAlertTag.TEST_TIMING.getTag()), is(equalTo(true)));
164166
assertThat(tags.containsKey(PolicyTag.DEV_FULL.getTag()), is(equalTo(true)));
165167
assertThat(tags.containsKey(PolicyTag.QA_STD.getTag()), is(equalTo(true)));
166168
assertThat(tags.containsKey(PolicyTag.QA_FULL.getTag()), is(equalTo(true)));

0 commit comments

Comments
 (0)