CVE-2024-27289
pgx SQL Injection via Line Comment Creation
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.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- High
- Privileges needed
- None
- User interaction
- None
What an attacker can affect
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Exploit likelihood
What each source reports
CVE List Score used
8.1
pgx SQL Injection via Line Comment Creation
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.
- Record
CVE-2024-27289- CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-89
- Updated
- 2026-11-02
EUVDEUVD-2024-0962
8.1
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.
- Record
EUVD-2024-0962- CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-m7wr-2xf7-cm9p
8.7
pgx SQL Injection via Line Comment Creation
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.
- Record
GHSA-m7wr-2xf7-cm9p- CVSS 4.0
- 8.7 High
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 - CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-89
- Updated
- 2026-11-02
NVD
8.1
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.
- Record
CVE-2024-27289- CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-89
- Updated
- 2026-11-02
OSV
8.1
pgx SQL Injection via Line Comment Creation
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.
- Record
CVE-2024-27289- CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-89
- Updated
- 2026-11-02
OSVDEBIAN-CVE-2024-27289
8.1
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.
- Record
DEBIAN-CVE-2024-27289- CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
Show 5 moreShow less
OSVGHSA-m7wr-2xf7-cm9p
8.7
pgx SQL Injection via Line Comment Creation
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.
- Record
GHSA-m7wr-2xf7-cm9p- CVSS 4.0
- 8.7 High
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 - CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-89
- Updated
- 2026-11-02
OSVUBUNTU-CVE-2024-27289
8.1
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.
- Record
UBUNTU-CVE-2024-27289- CVSS 3.1
- 8.1 High
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H - Updated
- 2026-11-02
OSVAZL-35750 No score
CVE-2024-27289 affecting package telegraf for versions less than 1.31.0-1
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.
- Record
AZL-35750- Updated
- 2026-11-02
OSVAZL-35763 No score
CVE-2024-27289 affecting package telegraf for versions less than 1.29.4-4
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.
- Record
AZL-35763- Updated
- 2026-11-02
OSVGO-2024-2605 No score
SQL injection in github.com/jackc/pgx/v4
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.
- Record
GO-2024-2605- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
github.com/jackc/pgxGo |
before 4.18.2 | 4.18.2 |
github.com/jackc/pgx/v4Go |
before 4.18.2 | 4.18.2 |
telegrafAzure Linux:3 |
before 1.31.0-1 | 1.31.0-1 |
telegrafAzure Linux:2 |
before 1.29.4-4 | 1.29.4-4 |
golang-github-jackc-pgxDebian:12 |
All versions, plus listed versions 4.15.0-44.18.1-14.18.1-24.18.3-14.18.3-1~exp04.18.3-2 |
None known |
golang-github-jackc-pgxDebian:13 |
before 4.18.1-2 | 4.18.1-2 |
golang-github-jackc-pgxDebian:14 |
before 4.18.1-2 | 4.18.1-2 |
github.com/jackc/pgxGo |
All versions | None known |
golang-github-jackc-pgxUbuntu:22.04:LTS |
All versions, plus listed versions 3.6.2-2 |
None known |
golang-github-jackc-pgxUbuntu:24.04:LTS |
All versions, plus listed versions 4.15.0-44.18.1-1 |
None known |
golang-github-jackc-pgxUbuntu:25.10 |
All versions, plus listed versions 4.18.1-14.18.1-2 |
None known |
golang-github-jackc-pgxUbuntu:26.10 |
All versions, plus listed versions 4.18.1-24.18.3-2 |
None known |
golang-github-jackc-pgxUbuntu:26.04:LTS |
All versions, plus listed versions 4.18.1-2 |
None known |
History
| Recorded | Changed | Sources |
|---|---|---|
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2024-27289 is a high vulnerability (CVSS 8.1) in Jackc Pgx, published March 4, 2024. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.85%, the 58th percentile. Fixed in github.com/jackc/pgx 4.18.2.
References
github.com/jackc/pgx/security/advisories/GHSA-m7wr-2xf7-cm9p
github.com/jackc/pgx/commit/f94eb0e2f96782042c96801b5ac448f44f0a81df
sonarsource.com/blog/double-dash-double-trouble-a-subtle-sql-injection-flaw
nvd.nist.gov/vuln/detail/CVE-2024-27289
github.com/advisories/GHSA-m7wr-2xf7-cm9p
github.com/CVEProject/cvelistV5/tree/main/cves/2024/27xxx/CVE-2024-27289.json