{"id":"CVE-2009-2940","aliases":["DEBIAN-CVE-2009-2940","DSA-1911-1","EUVD-2022-5860","GHSA-xv6x-43gq-4hfj","PYSEC-2009-18"],"status":"published","title":"PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection","description":"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.","severity":{"version":"2.0","score":7.5,"vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","level":"high","assessor":"primary","from":"nvd"},"epss":{"day":"2026-11-09","score":0.02702,"percentile":0.86047,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-89"],"published":"2009-10-14T00:00:00Z","modified":"2026-10-23T17:47:33Z","fixes":[{"ecosystem":"PyPI","package":"pygresql","fixed_in":["4.1"],"sources":["ghsa","osv"]},{"ecosystem":"Debian:12","package":"pygresql","fixed_in":["1:4.0-1"],"sources":["osv"]},{"ecosystem":"Debian:13","package":"pygresql","fixed_in":["1:4.0-1"],"sources":["osv"]},{"ecosystem":"Debian:14","package":"pygresql","fixed_in":["1:4.0-1"],"sources":["osv"]},{"ecosystem":"Debian:4.0","package":"pygresql","fixed_in":["1:3.8.1-1etch2"],"sources":["osv"]},{"ecosystem":"Debian:5.0","package":"pygresql","fixed_in":["1:3.8.1-3+lenny1"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"3.8.1"}]}]},{"source":"ghsa","ecosystem":"PyPI","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.0"},{"last_affected":"4.0"},{"fixed":"4.1"}]}],"versions":["4.0"]},{"source":"osv","ecosystem":"Debian:12","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1:4.0-1"}]}]},{"source":"osv","ecosystem":"Debian:13","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1:4.0-1"}]}]},{"source":"osv","ecosystem":"Debian:14","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1:4.0-1"}]}]},{"source":"osv","ecosystem":"Debian:4.0","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1:3.8.1-1etch2"}]}],"versions":["1:3.8.1-1","1:3.8.1-1etch1"]},{"source":"osv","ecosystem":"Debian:5.0","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1:3.8.1-3+lenny1"}]}],"versions":["1:3.8.1-3"]},{"source":"osv","ecosystem":"PyPI","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"3.8.1"}]}],"versions":["3.8.1"]},{"source":"osv","ecosystem":"PyPI","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.0"},{"fixed":"4.1"}]}],"versions":["4.0"]},{"source":"osv","ecosystem":"PyPI","package":"pygresql","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.8.1"},{"last_affected":"4.0"}]}],"versions":["3.8.1","4.0"]}],"products":[{"vendor":"pygresql","product":"pygresql"}],"references":[{"url":"http://secunia.com/advisories/37046","tags":["third-party-advisory","x_refsource_SECUNIA","x_transferred","Vendor Advisory","advisory"]},{"url":"http://www.debian.org/security/2009/dsa-1911","tags":["vendor-advisory","x_refsource_DEBIAN","x_transferred","advisory","web"]},{"url":"http://www.osvdb.org/59028","tags":["vdb-entry","x_refsource_OSVDB","x_transferred","web"]},{"url":"http://ubuntu.com/usn/usn-870-1","tags":["vendor-advisory","x_refsource_UBUNTU","x_transferred","web"]},{"url":"http://secunia.com/advisories/37654","tags":["third-party-advisory","x_refsource_SECUNIA","x_transferred","advisory"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2009-2940","tags":["advisory"]},{"url":"https://github.com/PyGreSQL/PyGreSQL/commit/8e19320b130946eed6f043297e3e4e005a523612","tags":["web"]},{"url":"https://github.com/PyGreSQL/PyGreSQL/commit/f7237d773e6f4d5a7da3d99bb6bc5062bd07935e","tags":["web"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/pygresql/PYSEC-2009-18.yaml","tags":["web"]},{"url":"https://github.com/advisories/GHSA-xv6x-43gq-4hfj","tags":["advisory"]},{"url":"https://security-tracker.debian.org/tracker/CVE-2009-2940","tags":["advisory"]},{"url":"https://github.com/PyGreSQL/PyGreSQL","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2009-2940","description":"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.","status":"published","published":"2009-10-22T16:00:00Z","modified":"2024-08-07T06:07:37.303Z","updated_at":"2026-11-02T14:33:23.395558Z"}],"euvd":[{"id":"EUVD-2022-5860","description":"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.","status":"published","published":"2009-10-22T16:00:00Z","modified":"2024-08-07T06:07:37Z","updated_at":"2026-11-03T01:39:15.098818Z"}],"ghsa":[{"id":"GHSA-xv6x-43gq-4hfj","title":"PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection","description":"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:\n\n```python\nimport pg\nconnection = pg.connect(...)\nescaped = pg.escape_string(untrusted_input)\n```\nshould be adjusted to use:\n\n```python\nimport pg\nconnection = pg.connect(...)\nescaped = connection.escape_string(untrusted_input)\n```","status":"published","published":"2022-05-02T03:40:08Z","modified":"2026-06-08T19:04:55Z","cwes":["CWE-89"],"updated_at":"2026-11-02T14:40:18.682012Z"}],"nvd":[{"id":"CVE-2009-2940","description":"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.","status":"published","published":"2009-10-22T16:30:00.25Z","modified":"2026-06-16T23:10:32.623Z","cvss":[{"version":"2.0","score":7.5,"vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","level":"high","assessor":"primary"}],"updated_at":"2026-11-02T14:01:37.004244Z"}],"osv":[{"id":"CVE-2009-2940","description":"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.","status":"published","published":"2009-10-22T16:30:00Z","modified":"2026-05-20T08:11:27.458437139Z","updated_at":"2026-11-02T15:43:57.714116Z"},{"id":"DEBIAN-CVE-2009-2940","description":"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.","status":"published","published":"2009-10-22T16:30:00.25Z","modified":"2026-10-23T17:47:33.183370016Z","updated_at":"2026-11-02T15:45:24.013654Z"},{"id":"DSA-1911-1","title":"pygresql - missing escape function","status":"published","published":"2009-10-14T00:00:00Z","modified":"2026-03-09T01:20:57.747096Z","updated_at":"2026-11-02T15:46:14.734124Z"},{"id":"GHSA-xv6x-43gq-4hfj","title":"PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection","description":"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:\n\n```python\nimport pg\nconnection = pg.connect(...)\nescaped = pg.escape_string(untrusted_input)\n```\nshould be adjusted to use:\n\n```python\nimport pg\nconnection = pg.connect(...)\nescaped = connection.escape_string(untrusted_input)\n```","status":"published","published":"2022-05-02T03:40:08Z","modified":"2026-06-08T19:15:12.507974558Z","cwes":["CWE-89"],"updated_at":"2026-11-02T15:47:00.604718Z"},{"id":"PYSEC-2009-18","description":"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.","status":"published","published":"2009-10-22T16:30:00.25Z","modified":"2026-06-10T17:01:44.540836585Z","updated_at":"2026-11-02T15:52:51.254177Z"}]}}
