CVE-2009-2940: SQL Injection

Published Oct 22, 2009
·
Updated

PyGreSQL 3.8 did not use PostgreSQL’s safe string and bytea functions in its own escaping functions. As a result, applications written to use PyGreSQL’s escaping functions are vulnerable to SQL injections when processing certain multi-byte character sequences. Because the safe functions require a database connection, to maintain backwards compatibility, pg.escapestring() and pg.escapebytea() are still available, but applications will have to be adjusted to use the new pyobj.escapestring() and pyobj.escapebytea() functions. For example, code containing:

python import pg connection = pg.connect(...) escaped = pg.escapestring(untrustedinput) should be adjusted to use:

python import pg connection = pg.connect(...) escaped = connection.escapestring(untrustedinput)

Other sources

The pygresql module 3.8.1 and 4.0 for Python does not properly support the PQescapeStringConn function, which might allow remote attackers to leverage escaping issues involving multibyte character encodings.

Affected Software

8 affected componentsFixes available
pip/PyGreSQL=4.0
4.1
pip/PyGreSQL<=3.8.1
All of the following
Any of the following
pygresql pygresql=3.8.1
pygresql pygresql=4.0
Python Python
pygresql pygresql=3.8.1
pygresql pygresql=4.0
Python Python

Event History

Oct 22, 2009
CVE Published
via MITRE·04:00 PM
Data Sourced
via MITRE·04:00 PM
Description
Data Sourced
04:30 PM
DescriptionWeaknessAffected Software
May 2, 2022
Advisory Published
via GitHub·03:40 AM

Frequently Asked Questions

1

What is the severity of CVE-2009-2940?

CVE-2009-2940 is categorized as a medium severity vulnerability due to the risk of SQL injection.

2

How do I fix CVE-2009-2940?

To fix CVE-2009-2940, upgrade PyGreSQL to version 4.1 or later.

3

Which versions of PyGreSQL are affected by CVE-2009-2940?

CVE-2009-2940 affects PyGreSQL versions up to and including 3.8.1.

4

What type of vulnerability is CVE-2009-2940?

CVE-2009-2940 is an SQL injection vulnerability arising from improper handling of multi-byte character sequences.

5

What is the impact of CVE-2009-2940?

The impact of CVE-2009-2940 can allow an attacker to execute arbitrary SQL commands in affected applications.

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