8.1high
pgx SQL Injection via Line Comment Creation
- Severity
- 8.1high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.85% (higher than 59% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-m7wr-2xf7-cm9pGO-2024-2605
Description
pgx is a PostgreSQL driver and toolkit for Go. Prior to version 4.18.2, SQL injection can occur when all of the following conditions are met: the non-default simple protocol is used; 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; and both parameter values must be user-controlled. The problem is resolved in v4.18.2. As a workaround, do not use the simple protocol or do not place a minus directly before a placeholder.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| jackc pgx | < 4.18.2, before 4.18.2 | CVE List, NVD |
| github.com/jackc/pgx (Go) | before 4.18.2, all versions | GitHub Advisory Database, Go Vulnerability Database |
| github.com/jackc/pgx/v4 (Go) | before 4.18.2 | GitHub Advisory Database, Go Vulnerability Database |
All scores
| GitHub_M | 8.1high CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| GitHub | 8.1high CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.
What each source says
CVE List
pgx is a PostgreSQL driver and toolkit for Go. Prior to version 4.18.2, SQL injection can occur when all of the following conditions are met: the non-default simple protocol is used; 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; and both parameter values must be user-controlled. The problem is resolved in v4.18.2. As a workaround, do not use the simple protocol or do not place a minus directly before a placeholder.
GitHub Advisory Database
Impact
SQL injection can occur when all of the following conditions are met:
- The non-default simple protocol is used.
- 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.
- Both parameter values must be user-controlled.
e.g.
Simple mode must be enabled:
// connection string includes "prefer_simple_protocol=true"
// or
// directly enabled in code
config.ConnConfig.PreferSimpleProtocol = true
Parameterized query:
SELECT * FROM example WHERE result=-$1 OR name=$2;
Parameter values:
$1 => -42
$2 => "foo\n 1 AND 1=0 UNION SELECT * FROM secrets; --"
Resulting query after preparation:
SELECT * FROM example WHERE result=--42 OR name= 'foo
1 AND 1=0 UNION SELECT * FROM secrets; --';
Patches
The problem is resolved in v4.18.2.
Workarounds
Do not use the simple protocol or do not place a minus directly before a placeholder.
Go Vulnerability Database
SQL injection is possible when the database uses the non-default simple protocol, a minus sign directly precedes a numeric placeholder followed by a string placeholder on the same line, and both parameter values are user-controlled.
NVD (es)
pgx es un controlador PostgreSQL y un conjunto de herramientas para Go. Antes de la versión 4.18.2, la inyección SQL puede ocurrir cuando se cumplen todas las condiciones siguientes: se utiliza el protocolo simple no predeterminado; un marcador de posición para un valor numérico debe ir precedido inmediatamente de un signo menos; debe haber un segundo marcador de posición para un valor de cadena después del primer marcador de posición; ambos deben estar en la misma línea; y ambos valores de parámetros deben ser controlados por el usuario. El problema se resuelve en v4.18.2. Como solución alternativa, no utilice el protocolo simple ni coloque un signo menos directamente antes de un marcador de posición.
References
Related
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-27289 changed 2025-06-12 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-m7wr-2xf7-cm9p changed 2026-09-10 | CC-BY-4.0 |
| Go Vulnerability Database | GO-2024-2605 changed 2026-02-04 | CC-BY-4.0 |
| NVD | CVE-2024-27289 changed 2026-06-17 | Public domain |