CVE-2024-27289: pgx SQL Injection via Line Comment Creation

Published Mar 4, 2024
·
Updated

Impact

SQL injection can occur when all of the following conditions are met:

1. The non-default simple protocol is used. 2. A placeholder for a numeric value must be immediately preceded by a minus. 3. There must be a second placeholder for a string value after the first placeholder; both must be on the same line. 4. Both parameter values must be user-controlled.

e.g.

Simple mode must be enabled:

go // connection string includes "prefersimpleprotocol=true" // or // directly enabled in code config.ConnConfig.PreferSimpleProtocol = true

Parameterized query:

sql SELECT FROM example WHERE result=-$1 OR name=$2;

Parameter values:

$1 => -42 $2 => "foo\n 1 AND 1=0 UNION SELECT FROM secrets; --"

Resulting query after preparation:

sql SELECT FROM example WHERE result=--42 OR name= 'foo 1 AND 1=0 UNION SELECT FROM secrets; --';

Patches

The problem is resolved in v4.18.2.

Workarounds

Do not use the simple protocol or do not place a minus directly before a placeholder.

Other sources

pgx is a PostgreSQL driver and toolkit for Go. Prior to version 4.18.2, SQL injection can occur when all of the following conditions are met: the non-default simple protocol is used; a placeholder for a numeric value must be immediately preceded by a minus; there must be a second placeholder for a string value after the first placeholder; both must be on the same line; and both parameter values must be user-controlled. The problem is resolved in v4.18.2. As a workaround, do not use the simple protocol or do not place a minus directly before a placeholder.

MITRE

pgx SQL Injection via Line Comment Creation

Microsoft

Affected Software

9 affected componentsFixes available
go/github.com/jackc/pgx/v4<4.18.2
4.18.2
go/github.com/jackc/pgx<4.18.2
4.18.2
Microsoft cbl2 telegraf 1.29.4-4
Microsoft azl3 telegraf 1.31.0-1
Microsoft azl3 telegraf 1.29.4-1
Microsoft cbl2 telegraf 1.29.4-15
Microsoft cbl2 telegraf 1.29.4-15
redhat/pgx<4.18.2
4.18.2
jackc Pgx Go<4.18.2

Event History

Mar 4, 2024
Advisory Published
via GitHub·08:13 PM
Data Sourced
via GitHub·08:13 PM
DescriptionSeverityWeaknessAffected Software
Mar 6, 2024
CVE Published
via MITRE·06:28 PM
Data Sourced
via MITRE·06:28 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·07:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·07:15 PM
RemedyAffected Software
Mar 7, 2024
Data Sourced
via Red Hat·05:53 PM
DescriptionSeverityAffected Software
Mar 11, 2024
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity
Updated
via Microsoft·07:00 AM
Description
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-27289?

CVE-2024-27289 has a medium severity rating due to its potential for SQL injection leading to unauthorized database access.

2

How do I fix CVE-2024-27289?

To mitigate CVE-2024-27289, update the affected packages to version 4.18.2 or later of pgx.

3

What software is affected by CVE-2024-27289?

CVE-2024-27289 affects the pgx packages from both GitHub and Red Hat, specifically versions below 4.18.2.

4

What type of vulnerability is CVE-2024-27289?

CVE-2024-27289 is an SQL injection vulnerability that can be exploited under specific conditions.

5

What are the conditions for the CVE-2024-27289 vulnerability to occur?

The vulnerability occurs when a non-default simple protocol is used, a numeric placeholder is preceded by a minus, and there is a second placeholder for a string value.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203