SQL Injection in pgx via Protocol Message Size Integer Overflow
CVE-2024-27304 is a SQL injection vulnerability in pgx, a PostgreSQL driver and toolkit for Go. The flaw occurs when an attacker can cause a single PostgreSQL query or bind protocol message to exceed 4 GB in size. In that condition, an integer overflow in the driver's calculated message size can cause what should be one large message to be emitted as multiple protocol messages under attacker control. This breaks the intended framing of the PostgreSQL wire protocol and can allow attacker-influenced SQL to be interpreted separately, resulting in SQL injection. Fixed releases are pgx v4.18.2 and v5.5.4.
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
What an attacker gets, and what they’ve been doing with it.
Successful exploitation can allow an attacker to transform oversized application input into attacker-controlled PostgreSQL protocol message boundaries, leading to SQL injection against the backend database. Depending on application behavior and database privileges, this can enable unauthorized query execution, modification or deletion of data, disclosure of sensitive information, and potentially broader compromise of database integrity.
If you can’t patch tonight, do this now.
If immediate upgrade is not possible, enforce strict input size limits so that no single query or bind message can exceed 4 GB. Validate and reject oversized user-controlled inputs before they are incorporated into database operations. Additional defensive measures such as minimizing database privileges and using safer query construction patterns may reduce impact, but they do not replace upgrading.
Patch, then assume compromise.
Upgrade pgx to a fixed version. For v4 branches, upgrade to v4.18.2 or later. For v5 branches, upgrade to v5.5.4 or later. Ensure downstream products and applications that vendor or bundle pgx also incorporate the corrected dependency version.
2 exploits validated by Mallory's analysis.
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
2 sources tracked across advisories and community write-ups. News coverage will land here when it surfaces.
No news coverage yet. Advisories and community discussion only.