Skip to content

Commit 8a00982

Browse files
committed
ascanrules: SQLi Oracle rename scan rule (all time based)
Signed-off-by: kingthorin <[email protected]>
1 parent 8afbdb0 commit 8a00982

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

addOns/ascanrules/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1212
- Rules (as applicable) have been tagged in relation to HIPAA and PCI DSS.
1313
- The Cloud Metadata Potentially Exposed scan rules now has a CWE reference.
1414
- Scan rules which execute time based attacks now include the "TEST_TIMING" alert tag.
15+
- The SQL Injection - Oracle scan rule and alerts have been renamed to clarify that they're time based (Issue 7341).
1516

1617
## [72] - 2025-06-20
1718
### Added
Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
/**
3939
* TODO: maybe implement a more specific UNION based check for Oracle (with table names)
4040
*
41-
* <p>The SqlInjectionOracleScanRule identifies Oracle specific SQL Injection vulnerabilities using
42-
* Oracle specific syntax. If it doesn't use Oracle specific syntax, it belongs in the generic
43-
* SQLInjection class! Note the ordering of checks, for efficiency is : 1) Error based (N/A) 2)
44-
* Boolean Based (N/A - uses standard syntax) 3) UNION based (TODO) 4) Stacked (N/A - uses standard
45-
* syntax) 5) Blind/Time Based (Yes)
41+
* <p>This scan rule identifies Oracle specific SQL Injection vulnerabilities using Oracle specific
42+
* syntax. If it doesn't use Oracle specific syntax, it belongs in the generic SQLInjection class!
43+
* Note the ordering of checks, for efficiency is : 1) Error based (N/A) 2) Boolean Based (N/A -
44+
* uses standard syntax) 3) UNION based (TODO) 4) Stacked (N/A - uses standard syntax) 5) Blind/Time
45+
* Based (Yes)
4646
*
4747
* <p>See the following for some great specific tricks which could be integrated here
4848
* http://www.websec.ca/kb/sql_injection
@@ -60,15 +60,13 @@
6060
*
6161
* @author 70pointer
6262
*/
63-
public class SqlInjectionOracleScanRule extends AbstractAppParamPlugin
63+
public class SqlInjectionOracleTimingScanRule extends AbstractAppParamPlugin
6464
implements CommonActiveScanRuleInfo {
6565

6666
private int expectedDelayInMs = 5000;
6767

68-
private boolean doUnionBased = false; // TODO: use in Union based, when we implement it
6968
private boolean doTimeBased = false;
7069

71-
private int doUnionMaxRequests = 0; // TODO: use in Union based, when we implement it
7270
private int doTimeMaxRequests = 0;
7371

7472
/** Oracle one-line comment */
@@ -167,7 +165,8 @@ public class SqlInjectionOracleScanRule extends AbstractAppParamPlugin
167165
}
168166

169167
/** for logging. */
170-
private static final Logger LOGGER = LogManager.getLogger(SqlInjectionOracleScanRule.class);
168+
private static final Logger LOGGER =
169+
LogManager.getLogger(SqlInjectionOracleTimingScanRule.class);
171170

172171
@Override
173172
public int getId() {
@@ -212,23 +211,15 @@ public void init() {
212211
if (this.getAttackStrength() == AttackStrength.LOW) {
213212
doTimeBased = true;
214213
doTimeMaxRequests = 3;
215-
doUnionBased = true;
216-
doUnionMaxRequests = 3;
217214
} else if (this.getAttackStrength() == AttackStrength.MEDIUM) {
218215
doTimeBased = true;
219216
doTimeMaxRequests = 5;
220-
doUnionBased = true;
221-
doUnionMaxRequests = 5;
222217
} else if (this.getAttackStrength() == AttackStrength.HIGH) {
223218
doTimeBased = true;
224219
doTimeMaxRequests = 10;
225-
doUnionBased = true;
226-
doUnionMaxRequests = 10;
227220
} else if (this.getAttackStrength() == AttackStrength.INSANE) {
228221
doTimeBased = true;
229222
doTimeMaxRequests = 100;
230-
doUnionBased = true;
231-
doUnionMaxRequests = 100;
232223
}
233224
}
234225

@@ -256,7 +247,6 @@ public void scan(HttpMessage originalMessage, String paramName, String paramValu
256247
long originalTimeUsed = msgTimeBaseline.getTimeElapsedMillis();
257248
// end of timing baseline check
258249

259-
int countUnionBasedRequests = 0;
260250
int countTimeBasedRequests = 0;
261251

262252
LOGGER.debug(

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
@@ -404,7 +404,7 @@ <H2 id="id-40021">SQL Injection - Oracle (Time Based)</H2>
404404
<br>
405405
Note that this rule does not currently allow you to change the length of time used for the timing attacks due to the way the delay is caused.
406406
<p>
407-
Latest code: <a href="https://github.com/zaproxy/zap-extensions/blob/main/addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/SqlInjectionOracleScanRule.java">SqlInjectionOracleScanRule.java</a>
407+
Latest code: <a href="https://github.com/zaproxy/zap-extensions/blob/main/addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/SqlInjectionOracleTimingScanRule.java">SqlInjectionOracleTimingScanRule.java</a>
408408
<br>
409409
Alert ID: <a href="https://www.zaproxy.org/docs/alerts/40021/">40021</a>.
410410

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
@@ -185,7 +185,7 @@ ascanrules.sqlinjection.mssql.alert.timebased.extrainfo = The query time is cont
185185
ascanrules.sqlinjection.mssql.name = SQL Injection - MsSQL
186186
ascanrules.sqlinjection.mysql.name = SQL Injection - MySQL
187187
ascanrules.sqlinjection.name = SQL Injection
188-
ascanrules.sqlinjection.oracle.name = SQL Injection - Oracle
188+
ascanrules.sqlinjection.oracle.name = SQL Injection - Oracle (Time Based)
189189
ascanrules.sqlinjection.postgres.name = SQL Injection - PostgreSQL
190190
ascanrules.sqlinjection.refs = https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
191191
ascanrules.sqlinjection.soln = Do not trust client side input, even if there is client side validation in place.\nIn general, type check all data on the server side.\nIf the application uses JDBC, use PreparedStatement or CallableStatement, with parameters passed by '?'\nIf the application uses ASP, use ADO Command Objects with strong type checking and parameterized queries.\nIf database Stored Procedures can be used, use them.\nDo *not* concatenate strings into queries in the stored procedure, or use 'exec', 'exec immediate', or equivalent functionality!\nDo not create dynamic SQL queries using simple string concatenation.\nEscape all data received from the client.\nApply an 'allow list' of allowed characters, or a 'deny list' of disallowed characters in user input.\nApply the principle of least privilege by using the least privileged database user possible.\nIn particular, avoid using the 'sa' or 'db-owner' database users. This does not eliminate SQL injection, but minimizes its impact.\nGrant the minimum database access that is necessary for the application.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@
3636
import org.zaproxy.zap.model.TechSet;
3737
import org.zaproxy.zap.testutils.NanoServerHandler;
3838

39-
/** Unit test for {@link SqlInjectionOracleScanRule}. */
40-
class SqlInjectionOracleScanRuleUnitTest extends ActiveScannerTest<SqlInjectionOracleScanRule> {
39+
/** Unit test for {@link SqlInjectionOracleTimingScanRule}. */
40+
class SqlInjectionOracleTimingScanRuleUnitTest
41+
extends ActiveScannerTest<SqlInjectionOracleTimingScanRule> {
4142

4243
@Override
43-
protected SqlInjectionOracleScanRule createScanner() {
44-
return new SqlInjectionOracleScanRule();
44+
protected SqlInjectionOracleTimingScanRule createScanner() {
45+
return new SqlInjectionOracleTimingScanRule();
4546
}
4647

4748
@Test

0 commit comments

Comments
 (0)