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.
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.
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.
### Impact
SQL injection can occur when all of the following conditions are met:
1. The non-default simple protocol is used.
2. A placeholder for a numeric value must be immediately preceded by a minus.
3. There must be a second placeholder for a string value after the first placeholder; both
must be on the same line.
4. Both parameter values must be user-controlled.
e.g.
Simple mode must be enabled:
```go
// connection string includes "prefer_simple_protocol=true"
// or
// directly enabled in code
config.ConnConfig.PreferSimpleProtocol = true
```
Parameterized query:
```sql
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:
```sql
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.
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.
EUVD source date text has no stated timezone and is retained without inventing a UTC instant. Related bulletin membership is not an alias, common cause or applicability claim. A missing vector with a zero score is treated as unrated. Complete vendor/product and underlying source evidence remains in the original JSON.
Original publisher date fields
datePublished: Mar 6, 2024, 6:28:12 PM
dateUpdated: Jun 12, 2025, 3:45:56 PM
5 related source bulletins · separate from aliases
WID-SEC-W-2024-0626: Red Hat Enterprise Linux: Mehrere Schwachstellen ermöglichen Manipulation von Dateien
CVE-2024-27289 · CVE-2024-27304
RHSA-2024:1321: Red Hat Security Advisory: ACS 4.3 enhancement and security update
CVE-2024-27289 · CVE-2024-27304
RHSA-2024:7922: Red Hat Security Advisory: OpenShift Container Platform 4.17.1 bug fix and security update
msrc_CVE-2024-27289: pgx SQL Injection via Line Comment Creation
CVE-2024-27289
RHSA-2024:7944: Red Hat Security Advisory: OpenShift Container Platform 4.16.17 security update
CVE-2024-27289
No normalized affected-package data is projected for this source revision. The original publisher record may contain additional product and version evidence; this does not establish that a package is unaffected.
NVD analysis and CPE criteria are source context, not proof that a package or your environment is affected. Complete affected data, logical configurations and SSVC are retained in the original JSON.
Source analysis status: Analyzed
Weakness classifications: CWE-89
Original publisher date fields
published: 2024-03-06T19:15:08.140
lastModified: 2026-06-17T07:19:34.997
1 source CPE criteria · context only
cpe:2.3:a:jackc:pgx:*:*:*:*:*:go:*:*
The original JSON retains the logical configuration operators, exclusions and version bounds.
No normalized affected-package data is projected for this source revision. The original publisher record may contain additional product and version evidence; this does not establish that a package is unaffected.