Skip to content

Commit da0b2ec

Browse files
committed
ascanrules: SQLi MySQL rename scan rule (all timing based)
Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
1 parent dc2e143 commit da0b2ec

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
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 - MySQL 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,19 +44,19 @@
4444
import org.zaproxy.zap.model.TechSet;
4545

4646
/**
47-
* The SqlInjectionMySqlScanRule identifies MySQL specific SQL Injection vulnerabilities using MySQL
48-
* specific syntax. If it doesn't use MySQL 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 SqlInjectionMySqlTimingScanRule identifies MySQL specific SQL Injection vulnerabilities using
48+
* MySQL specific syntax. If it doesn't use MySQL 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#MySQL_Stacked_Queries
5555
* http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
5656
*
5757
* @author 70pointer
5858
*/
59-
public class SqlInjectionMySqlScanRule extends AbstractAppParamPlugin
59+
public class SqlInjectionMySqlTimingScanRule extends AbstractAppParamPlugin
6060
implements CommonActiveScanRuleInfo {
6161

6262
/** MySQL one-line comment */
@@ -220,7 +220,8 @@ public class SqlInjectionMySqlScanRule extends AbstractAppParamPlugin
220220
CommonAlertTag.OWASP_2017_A01_INJECTION,
221221
CommonAlertTag.WSTG_V42_INPV_05_SQLI,
222222
CommonAlertTag.HIPAA,
223-
CommonAlertTag.PCI_DSS));
223+
CommonAlertTag.PCI_DSS,
224+
CommonAlertTag.TEST_TIMING));
224225
alertTags.put(PolicyTag.DEV_FULL.getTag(), "");
225226
alertTags.put(PolicyTag.QA_STD.getTag(), "");
226227
alertTags.put(PolicyTag.QA_FULL.getTag(), "");
@@ -230,7 +231,8 @@ public class SqlInjectionMySqlScanRule extends AbstractAppParamPlugin
230231
}
231232

232233
/** for logging. */
233-
private static final Logger LOGGER = LogManager.getLogger(SqlInjectionMySqlScanRule.class);
234+
private static final Logger LOGGER =
235+
LogManager.getLogger(SqlInjectionMySqlTimingScanRule.class);
234236

235237
private int timeSleepSeconds = DEFAULT_SLEEP_TIME;
236238

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
@@ -183,7 +183,7 @@ 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.
185185
ascanrules.sqlinjection.mssql.name = SQL Injection - MsSQL
186-
ascanrules.sqlinjection.mysql.name = SQL Injection - MySQL
186+
ascanrules.sqlinjection.mysql.name = SQL Injection - MySQL (Time Based)
187187
ascanrules.sqlinjection.name = SQL Injection
188188
ascanrules.sqlinjection.oracle.name = SQL Injection - Oracle
189189
ascanrules.sqlinjection.postgres.name = SQL Injection - PostgreSQL
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 SqlInjectionMySqlScanRule}. */
42-
class SqlInjectionMySqlScanRuleUnitTest extends ActiveScannerTest<SqlInjectionMySqlScanRule> {
41+
/** Unit test for {@link SqlInjectionMySqlTimingScanRule}. */
42+
class SqlInjectionMySqlTimingScanRuleUnitTest
43+
extends ActiveScannerTest<SqlInjectionMySqlTimingScanRule> {
4344

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

4950
@Test
@@ -149,7 +150,7 @@ void shouldReturnExpectedMappings() {
149150
// Then
150151
assertThat(cwe, is(equalTo(89)));
151152
assertThat(wasc, is(equalTo(19)));
152-
assertThat(tags.size(), is(equalTo(10)));
153+
assertThat(tags.size(), is(equalTo(11)));
153154
assertThat(
154155
tags.containsKey(CommonAlertTag.OWASP_2021_A03_INJECTION.getTag()),
155156
is(equalTo(true)));
@@ -160,6 +161,7 @@ void shouldReturnExpectedMappings() {
160161
tags.containsKey(CommonAlertTag.WSTG_V42_INPV_05_SQLI.getTag()), is(equalTo(true)));
161162
assertThat(tags.containsKey(CommonAlertTag.HIPAA.getTag()), is(equalTo(true)));
162163
assertThat(tags.containsKey(CommonAlertTag.PCI_DSS.getTag()), is(equalTo(true)));
164+
assertThat(tags.containsKey(CommonAlertTag.TEST_TIMING.getTag()), is(equalTo(true)));
163165
assertThat(tags.containsKey(PolicyTag.DEV_FULL.getTag()), is(equalTo(true)));
164166
assertThat(tags.containsKey(PolicyTag.QA_STD.getTag()), is(equalTo(true)));
165167
assertThat(tags.containsKey(PolicyTag.QA_FULL.getTag()), is(equalTo(true)));

0 commit comments

Comments
 (0)