🛡️ CVE-2009-2940 — pygresql
Description
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:
```python
import pg
connection = pg.connect(...)
escaped = pg.escape_string(untrusted_input)
```
should be adjusted to use:
```python
import pg
connection = pg.connect(...)
escaped = connection.escape_string(untrusted_input)
```
Weakness class
CVE-2009-2940 is classified as CWE-89: SQL Injection. Untrusted input is concatenated into an SQL statement, letting an attacker change the query and reach data the request should not return.
Affected software
CVE-2009-2940 is recorded against 1 package.
- pygresql (from 4.0 up to 4.1)
Timeline and source
Published on 2 May 2022 and last revised on 8 June 2026. No public exploit is currently recorded for this entry. Record sourced from OSV.
References
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Web)
github.com (Package)
github.com (Web)
ubuntu.com (Web)
www.debian.org (Web)
Details
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| pygresql | 4.0 | 4.1 |
References
More CVE 2009 advisories
Browse all of CVE 2009 in the advisory index.
Site Security Check
Is pygresql part of your stack?
CVE-2009-2940 is rated CVSS 8.0 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.
Scan My Site Free →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.