Skip to main content
Mallory
CriticalPublic exploitVulnerability

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

Published Mar 6, 2024 · Updated 1 month ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 daysNo mention activity in the last 30 days.
CVSS9.8Critical · v3.1
EPSS1.1%67th percentile
CISA KEVNoNot listed
In the wildNonePublic exploit, no exploitation reported
Vendors
Pgproto3 ProjectJackcPgx Project
IdentifiersCVE-2024-27304CWE-190 · Integer Overflow or Wraparound

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.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

Impact, mitigation & remediation

What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.

Impact

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.

Mitigation

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.

Remediation

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.

Public exploits

Exploits

2 exploits validated by Mallory's analysis.

View more in app →
Go-PGX-Vulnerability-POC-Public-MirrorThis repository contains both a vulnerable demo web application and two Python exploit implementations targeting the same underlying idea: abuse of PostgreSQL pgx-backed request handling by sending a massive streamed login field that embeds PostgreSQL wire-protocol messages and SQL statements. The Go application (main.go, handlers.go) is a small insurance dashboard with login, dashboard, and logout routes, PostgreSQL-backed users/sessions tables, HTML templates, and SQL setup scripts. The login flow is notable because it decodes attacker-supplied username data to a temporary file and then uses the decoded content in authentication logic, creating the attack surface exercised by the exploit scripts. Repository structure: main.go initializes the HTTP server and PostgreSQL pool from DATABASE_URL and PORT. handlers.go implements session management, CSRF handling, login/dashboard/logout handlers, and the base64 username decoding helper that writes to an OS temp subdirectory. SQL setup files create users and sessions tables, seed an admin account, and remove expired sessions. templates/ contains the login and dashboard UI. The insurance_demo_exploit/ directory contains the main exploit driver and a payload generator that streams a 2^32-byte payload as base64 inside the username form field to /login. The payload includes PostgreSQL protocol frames for SYNC, ROLLBACK, INSERT, and COMMIT, ultimately inserting a new demo user into the users table. The harbor_exploit/ directory adapts the same technique to Harbor’s /c/login endpoint, harvesting Harbor CSRF/session state and streaming a URL-encoded principal field that inserts a new sysadmin account into harbor_user. Main exploit capabilities: create unauthorized accounts directly in the backend database, including admin/sysadmin access; evade memory limits by streaming payloads in chunks; support small alignment offsets (0-4 bytes) to tune the NOP/padding placement; and target either the included demo app or Harbor. This is an actual exploit repository rather than a detector. It is operational because it contains working payload generation and delivery logic, but payloads and targets are largely hardcoded rather than fully generalized.flying-owl · Disclosed Mar 20, 2026 · go · python · network · http · database protocol smuggling via oversized streamed form inputOperationalCVE-2024-27304-PoCThis repository provides a proof-of-concept (PoC) exploit for CVE-2024-27304, a protocol-level SQL injection vulnerability in the pgx PostgreSQL driver (v5.5.3) when used in Simple Protocol mode. The repository contains a vulnerable web application (written in Go) that uses pgx to connect to a PostgreSQL database and exposes a /login endpoint. The exploit scripts (in Python) craft and send large, specially constructed HTTP POST requests to the /login endpoint, exploiting the way pgx handles PostgreSQL protocol messages to inject arbitrary SQL or cause a denial of service. The exploit requires knowledge of the query structure and is most effective when the application uses the Simple Protocol mode. The repository is structured with a 'webapp' directory containing the vulnerable application and a set of 'exploit' scripts demonstrating different attack techniques. The main attack vector is network-based, targeting the HTTP interface of the web application.roaris · Disclosed Oct 12, 2025 · python · go · networkPoC
Exposure surface

Affected products & vendors

Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.

VendorProductType
JackcPgproto3application
JackcPgxapplication
Pgproto3 ProjectPgproto3application
Pgx ProjectPgxapplication
FAQ

Frequently asked questions

Is CVE-2024-27304 exploited in the wild?
As of Oct 16, 2026, Mallory has no reports of CVE-2024-27304 being exploited in the wild. It is not listed in CISA KEV.
Is there a public exploit for CVE-2024-27304?
Yes. Mallory tracks 2 public exploits or proofs of concept for CVE-2024-27304, the earliest disclosed Oct 12, 2025.
Is there a patch for CVE-2024-27304?
Upgrade pgx to a fixed version. For v4 branches, upgrade to v4.18.2 or later.
What products are affected by CVE-2024-27304?
Pgx Project Pgx, Jackc Pgx, Pgproto3 Project Pgproto3, and Jackc Pgproto3.
How severe is CVE-2024-27304?
CVE-2024-27304 has a CVSS v3.1 score of 9.8 (Critical) and an EPSS score of 1.1% (67th percentile) as of Oct 16, 2026.
Activity feed

Recent activity

2 sources tracked across advisories and community write-ups. News coverage will land here when it surfaces.

View more in app →

No news coverage yet. Advisories and community discussion only.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Mallory platform

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidenceEvery report linking this CVE to a named adversary.
Associated malwareMalware families linked to this CVE, with evidence and IOCs.
Detection signaturesYARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activity2Community discussion across Reddit, Mastodon, and other social sources.