Advisory Database
  • Advisories
  • Dependency Scanning
  1. golang
  2. ›
  3. github.com/jackc/pgx
  4. ›
  5. CVE-2024-27289

CVE-2024-27289: pgx SQL Injection via Line Comment Creation

March 4, 2024 (updated June 13, 2025)

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:

// 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; --';

References

  • github.com/advisories/GHSA-m7wr-2xf7-cm9p
  • github.com/jackc/pgx
  • github.com/jackc/pgx/commit/f94eb0e2f96782042c96801b5ac448f44f0a81df
  • github.com/jackc/pgx/security/advisories/GHSA-m7wr-2xf7-cm9p
  • nvd.nist.gov/vuln/detail/CVE-2024-27289
  • www.sonarsource.com/blog/double-dash-double-trouble-a-subtle-sql-injection-flaw

Code Behaviors & Features

Detect and mitigate CVE-2024-27289 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions before 4.18.2

Fixed versions

  • 4.18.2

Solution

Upgrade to version 4.18.2 or above.

Impact 8.1 HIGH

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Source file

go/github.com/jackc/pgx/CVE-2024-27289.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:15:33 +0000.