CVE-2009-2940
PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection
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
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 High
AV: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
| Package | Affected | Fixed |
|---|---|---|
pygresqlPyPI |
through 3.8.1 | None known |
pygresqlPyPI |
4.0 to 4.0 | 4.1 |
pygresqlDebian:12 |
before 1:4.0-1 | 1:4.0-1 |
pygresqlDebian:13 |
before 1:4.0-1 | 1:4.0-1 |
pygresqlDebian:14 |
before 1:4.0-1 | 1:4.0-1 |
pygresqlDebian: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 |
pygresqlDebian:5.0 |
before 1:3.8.1-3+lenny1, plus listed versions 1:3.8.1-3 |
1:3.8.1-3+lenny1 |
pygresqlPyPI |
4.0 up to 4.1 | 4.1 |
pygresqlPyPI |
3.8.1 to 4.0 | None known |
History
| When | Changed | Sources |
|---|---|---|
| 2026-11-03 | aliases | EUVD |
| 2026-11-02 | created | CVE List, GitHub Advisories, NVD, OSV |
References
secunia.com/advisories/37046
debian.org/security/2009/dsa-1911
osvdb.org/59028
ubuntu.com/usn/usn-870-1
secunia.com/advisories/37654
nvd.nist.gov/vuln/detail/CVE-2009-2940
Show 6 moreShow less
github.com/PyGreSQL/PyGreSQL/commit/8e19320b130946eed6f043297e3e4e005a523612
github.com/PyGreSQL/PyGreSQL/commit/f7237d773e6f4d5a7da3d99bb6bc5062bd07935e
github.com/pypa/advisory-database/tree/main/vulns/pygresql/PYSEC-2009-18.yaml
github.com/advisories/GHSA-xv6x-43gq-4hfj
security-tracker.debian.org/tracker/CVE-2009-2940
github.com/PyGreSQL/PyGreSQL