title: pgjdbc SQL Injection via line comment generation
description: pgjdbc, the PostgreSQL JDBC Driver, allows attacker to inject SQL if using PreferQueryMode=SIMPLE. Note this is not the default. In the default mode there is no vulnerability. A placeholder for a numeric value must be immediately preceded by a minus. There must be a second placeholder for a string value after the first placeholder; both must be on the same line. By constructing a matching string payload, the attacker can inject SQL to alter the query,bypassing the protections that parameterized queries bring against SQL Injection attacks. Versions before 42.7.2, 42.6.1, 42.5.5, 42.4.4, 42.3.9, and 42.2.8 are affected.
problem types: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
affected:
{
vendor: pgjdbc
product: pgjdbc
versions:
version: < 42.7.2, status: affected
version: < 42.6.1, status: affected
version: < 42.5.5, status: affected
version: < 42.4.4, status: affected
version: < 42.3.9, status: affected
version: < 42.2.8, status: affected
}
metrics:
cvssV3_1: [
version: 3.1
vectorString: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
attackVector: NETWORK
attackComplexity: LOW
privilegesRequired: NONE
userInteraction: NONE
scope: CHANGED
confidentialityImpact: HIGH
integrityImpact: HIGH
availabilityImpact: HIGH
baseScore: 10
baseSeverity: CRITICAL
]
workarounds: Don't use SimpleQuery mode