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

> SQL injection in pgx Go driver allows attackers to manipulate queries when using the non-default simple protocol with specific numeric and string placeholders.

- **Severity:** High 8.1 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Mar 2024
- **Updated:** 12 Jun 2025
- **Also known as:** AZL-35750, AZL-35763, CLEANSTART-2026-DM54086, CLEANSTART-2026-EY15087, DEBIAN-CVE-2024-27289, GHSA-m7wr-2xf7-cm9p, GO-2024-2605, UBUNTU-CVE-2024-27289

## What is CVE-2024-27289?

CVE-2024-27289 is a high-severity SQL injection vulnerability in jackc pgx, published on 6 Mar 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

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

## Which versions are affected by CVE-2024-27289?

6 open source packages ship an affected version, including github.com/jackc/pgx and github.com/jackc/pgx/v4. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/jackc/pgx` | Go | All versions | None |
| `github.com/jackc/pgx` | Go | All versions | 4.18.2 |
| `github.com/jackc/pgx` | Go | All versions | 4.18.2 |
| `github.com/jackc/pgx/v4` | Go | All versions | 4.18.2 |
| `github.com/jackc/pgx/v4` | Go | All versions | 4.18.2 |
| `github.com/jackc/pgx/v4` | Go | All versions | 4.18.2 |

Products: Jackc Pgx.

## How do I fix CVE-2024-27289?

Upgrade github.com/jackc/pgx to 4.18.2 or later.

## Is CVE-2024-27289 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-27289 exists.

## Other vulnerabilities in jackc pgx

- [CVE-2026-33815](https://insights.sbomify.com/CVE-2026-33815/): CVE-2026-33815 in github.com/jackc/pgx (critical 9.8)
- [CVE-2026-33816](https://insights.sbomify.com/CVE-2026-33816/): CVE-2026-33816 in github.com/jackc/pgx (critical 9.8)
- [CVE-2026-41889](https://insights.sbomify.com/CVE-2026-41889/): pgx: SQL Injection via placeholder confusion with dollar quoted string literals (low 2.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-27289 and fix it if it is affected.

What it is: CVE-2024-27289 is a high-severity SQL injection vulnerability in jackc pgx, published on 6 Mar 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-27289 exists.

Affected packages and fixed versions:
- github.com/jackc/pgx (Go): affected all versions; no fix listed
- github.com/jackc/pgx (Go): affected all versions; fixed in 4.18.2
- github.com/jackc/pgx (Go): affected all versions; fixed in 4.18.2
- github.com/jackc/pgx/v4 (Go): affected all versions; fixed in 4.18.2
- github.com/jackc/pgx/v4 (Go): affected all versions; fixed in 4.18.2
- github.com/jackc/pgx/v4 (Go): affected all versions; fixed in 4.18.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-27289/ (Markdown: https://insights.sbomify.com/CVE-2024-27289/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-27289
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-27289
- OSV: https://osv.dev/vulnerability/CVE-2024-27289

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-27289/
Summaries are generated and may contain mistakes; the official description above is the record.
