Every CVE Search/ Get API key

CVE-2009-2940

PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection

7.5 HighFix available

CVE-2009-2940 is a high vulnerability (CVSS 7.5) in Pygresql, published October 14, 2009. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 2.70%, the 85th percentile. Fixed in pygresql 4.1.

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.

Exploit likelihood

2.70%Up 1.5 points since Feb 4, 2022
90%50%10%1%

What each source reports

NVD Score used 7.5

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.

Record
CVE-2009-2940
CVSS 2.0
7.5 HighAV:N/AC:L/Au:N/C:P/I:P/A:P
Updated
2026-11-02
CVE List No score

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.

Record
CVE-2009-2940
Updated
2026-11-02
EUVDEUVD-2022-5860 No score

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.

Record
EUVD-2022-5860
Updated
2026-11-03
GitHub AdvisoriesGHSA-xv6x-43gq-4hfj No score

PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection

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.escape_string() and pg.escape_bytea() are still available, but applications will have to be adjusted to use the new pyobj.escape_string() and pyobj.escape_bytea() functions. For example, code containing:

import pg
connection = pg.connect(...)
escaped = pg.escape_string(untrusted_input)

should be adjusted to use:

import pg
connection = pg.connect(...)
escaped = connection.escape_string(untrusted_input)
Record
GHSA-xv6x-43gq-4hfj
Weakness
CWE-89
Updated
2026-11-02
OSV No score

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.

Record
CVE-2009-2940
Updated
2026-11-02
OSVDEBIAN-CVE-2009-2940 No score

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.

Record
DEBIAN-CVE-2009-2940
Updated
2026-11-02
OSVGHSA-xv6x-43gq-4hfj No score

PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection

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.escape_string() and pg.escape_bytea() are still available, but applications will have to be adjusted to use the new pyobj.escape_string() and pyobj.escape_bytea() functions. For example, code containing:

import pg
connection = pg.connect(...)
escaped = pg.escape_string(untrusted_input)

should be adjusted to use:

import pg
connection = pg.connect(...)
escaped = connection.escape_string(untrusted_input)
Record
GHSA-xv6x-43gq-4hfj
Weakness
CWE-89
Updated
2026-11-02
OSVPYSEC-2009-18 No score

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.

Record
PYSEC-2009-18
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
pygresql
PyPI
through 3.8.1 None known
pygresql
PyPI
4.0 to 4.0
4.1
pygresql
Debian:12
before 1:4.0-1
1:4.0-1
pygresql
Debian:13
before 1:4.0-1
1:4.0-1
pygresql
Debian:14
before 1:4.0-1
1:4.0-1
pygresql
Debian:4.0
before 1:3.8.1-1etch2, plus listed versions
1:3.8.1-11:3.8.1-1etch1
1:3.8.1-1etch2
pygresql
Debian:5.0
before 1:3.8.1-3+lenny1, plus listed versions
1:3.8.1-3
1:3.8.1-3+lenny1
pygresql
PyPI
4.0 up to 4.1
4.1
pygresql
PyPI
3.8.1 to 4.0 None known

History

History
WhenChangedSources
2026-11-03aliasesEUVD
2026-11-02createdCVE List, GitHub Advisories, NVD, OSV

References

Show 6 moreShow less
MoveEnter Open