pgx: SQL Injection via placeholder confusion with dollar quoted string literals
Published 22 Apr 2026 · Updated 10 Sept 2026
Is your project on an affected github.com/jackc/pgx/v5?
Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- <5.9.2
- Fixed in
- 5.9.2
go get github.com/jackc/pgx/v5@v5.9.2- Affected
- <=4.18.3
- Fixed in
- No fix released
- Affected
- <=3.6.2
- Fixed in
- No fix released
Details
Impact
SQL Injection can occur when:
1. The non-default simple protocol is used. 2. A dollar quoted string literal is used in the SQL query. 3. That string literal contains text that would be would be interpreted as a placeholder outside of a string literal. 4. The value of that placeholder is controllable by the attacker.
e.g.
attackValue := `$tag$; drop table canary; --` _, err = tx.Exec(ctx, `select $tag$ $1 $tag$, $1`, pgx.QueryExecModeSimpleProtocol, attackValue)
This is unlikely to occur outside of a contrived scenario.
Patches
The problem is resolved in v5.9.2.
Workarounds
Do not use the simple protocol to execute queries matching all the above conditions.
Is GHSA-j88v-2chj-qfwx in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected github.com/jackc/pgx/v5, and gives you the command that fixes it.
More advisories for github.com/jackc/pgx/v5
- CriticalCVE-2026-33816Memory-safety vulnerability in github.com/jackc/pgx/v5. · 7 Apr 2026
- CriticalCVE-2026-33815pgx contains memory-safety vulnerability · 7 Apr 2026
- LowCVE-2026-33815CVE-2026-33815 in github.com/jackc/pgx · 7 Apr 2026
- LowCVE-2026-33816CVE-2026-33816 in github.com/jackc/pgx · 7 Apr 2026
- MediumGHSA-fqpg-rq76-99pqPanic in Pipeline when PgConn is busy or closed in github.com/jackc/pgx · 5 Jul 2024
- LowGO-2024-2567Panic in Pipeline when PgConn is busy or closed in github.com/jackc/pgx · 2 Jul 2024
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.