Skip to content

Commit ecddf90

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

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
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 - PostgreSQL scan rule and alerts have been renamed to clarify that they're time based (Issue 7341).
1011

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

4444
/**
45-
* The SqlInjectionPostgreScanRule identifies Postgresql specific SQL Injection vulnerabilities
46-
* using Postgresql specific syntax. If it doesn't use Postgresql specific syntax, it belongs in the
47-
* generic SQLInjection class! Note the ordering of checks, for efficiency is : 1) Error based (N/A)
48-
* 2) Boolean Based (N/A - uses standard syntax) 3) UNION based (N/A - uses standard syntax) 4)
49-
* Stacked (N/A - uses standard syntax) 5) Blind/Time Based (Yes)
45+
* This scan rule identifies Postgresql specific SQL Injection vulnerabilities using Postgresql
46+
* specific syntax. If it doesn't use Postgresql specific syntax, it belongs in the generic
47+
* SQLInjection class! Note the ordering of checks, for efficiency is : 1) Error based (N/A) 2)
48+
* Boolean Based (N/A - uses standard syntax) 3) UNION based (N/A - uses standard syntax) 4) Stacked
49+
* (N/A - uses standard syntax) 5) Blind/Time Based (Yes)
5050
*
5151
* <p>See the following for some great specific tricks which could be integrated here
5252
* http://www.websec.ca/kb/sql_injection
@@ -60,7 +60,7 @@
6060
*
6161
* @author 70pointer
6262
*/
63-
public class SqlInjectionPostgreScanRule extends AbstractAppParamPlugin
63+
public class SqlInjectionPostgreSqlTimingScanRule extends AbstractAppParamPlugin
6464
implements CommonActiveScanRuleInfo {
6565

6666
private boolean doTimeBased = false;
@@ -209,7 +209,8 @@ public class SqlInjectionPostgreScanRule extends AbstractAppParamPlugin
209209
}
210210

211211
/** for logging. */
212-
private static final Logger LOGGER = LogManager.getLogger(SqlInjectionPostgreScanRule.class);
212+
private static final Logger LOGGER =
213+
LogManager.getLogger(SqlInjectionPostgreSqlTimingScanRule.class);
213214

214215
@Override
215216
public int getId() {

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
@@ -186,7 +186,7 @@ ascanrules.sqlinjection.mssql.name = SQL Injection - MsSQL
186186
ascanrules.sqlinjection.mysql.name = SQL Injection - MySQL
187187
ascanrules.sqlinjection.name = SQL Injection
188188
ascanrules.sqlinjection.oracle.name = SQL Injection - Oracle
189-
ascanrules.sqlinjection.postgres.name = SQL Injection - PostgreSQL
189+
ascanrules.sqlinjection.postgres.name = SQL Injection - PostgreSQL (Time Based)
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.
192192
ascanrules.sqlinjection.sqlite.alert.errorbased.extrainfo = The following known SQLite error message was provoked: [{0}].
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@
4141
import org.zaproxy.zap.model.TechSet;
4242
import org.zaproxy.zap.testutils.NanoServerHandler;
4343

44-
/** Unit test for {@link SqlInjectionPostgreScanRule}. */
45-
class SqlInjectionPostgreScanRuleUnitTest extends ActiveScannerTest<SqlInjectionPostgreScanRule> {
44+
/** Unit test for {@link SqlInjectionPostgreSqlTimingScanRule}. */
45+
class SqlInjectionPostgreSqlTimingScanRuleUnitTest
46+
extends ActiveScannerTest<SqlInjectionPostgreSqlTimingScanRule> {
4647

4748
@Override
48-
protected SqlInjectionPostgreScanRule createScanner() {
49-
return new SqlInjectionPostgreScanRule();
49+
protected SqlInjectionPostgreSqlTimingScanRule createScanner() {
50+
return new SqlInjectionPostgreSqlTimingScanRule();
5051
}
5152

5253
@Test

0 commit comments

Comments
 (0)