SQL Injection Risk in pgx Package: Vulnerability Overview

golang-github-jackc-pgx Updated 02 Oct 2025

Summary

06/03/2024
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2024-27304: pgx is a PostgreSQL driver and toolkit for Go. Affects golang-github-jackc-pgx versions < 4.18.1-2. Fixed in 4.18.1-2. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

pgx is a PostgreSQL driver and toolkit for the Go programming language, designed to facilitate seamless interaction with PostgreSQL databases. It provides a rich set of features, including connection pooling, prepared statements, and support for various PostgreSQL types. However, it is susceptible to a critical SQL injection vulnerability that can arise when handling large query or bind messages.

Vulnerability Detail

The vulnerability stems from an integer overflow that can occur when an attacker manipulates a single query or bind message to exceed 4 GB in size. This overflow can lead to the message being sent as multiple messages, potentially under the attacker's control. This situation poses a significant risk as it could allow unauthorized access to the database or manipulation of data, leading to severe security breaches.

How To Fix

Minimum fixed version

4.18.1-2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade golang-github-jackc-pgx

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, implement input validation to reject any user input that could lead to a single query or bind message exceeding 4 GB in size. This can be done by checking the size of the input before processing it. For example, in Go, you can use the following code snippet:

if len(userInput) > 4*1024*1024*1024 {
    return errors.New("Input size exceeds the allowed limit")
}

Conclusion

The pgx package has a critical vulnerability that can lead to SQL injection due to integer overflow when handling large messages. It is essential to update to the patched version or implement workarounds to mitigate the risk. Regular monitoring using tools like Vulert can help maintain security against such vulnerabilities.

See every vulnerability recorded for golang-github-jackc-pgx →

Share this vulnerability

FAQ

pgx is a PostgreSQL driver and toolkit for the Go programming language, providing features for database interaction.

The vulnerability allows for SQL injection through an integer overflow when handling large query messages, which can be exploited by attackers.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Implement input validation to reject large user inputs that could lead to the vulnerability until you can apply the patch.

Related vulnerabilities

Recent vulnerabilities recorded for golang-github-jackc-pgx.

How To Fix

Minimum fixed version

4.18.1-2

This is the first release that contains the fix.

sudo apt-get install --only-upgrade golang-github-jackc-pgx

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback