CVE-2009-2940: PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection
7.5
CVSS Score
Basic Information
CVE ID
GHSA ID
EPSS Score
0.71831%
CWE
Published
5/2/2022
Updated
2/8/2024
KEV Status
No
Technology
Python
Technical Details
CVSS Vector
AV:N/AC:L/Au:N/C:P/I:P/A:P
Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
---|---|---|---|
PyGreSQL | pip | <= 3.8.1 | |
PyGreSQL | pip | = 4.0 | 4.1 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability arises because PyGreSQL's module-level escaping functions (pg.escape_string and pg.escape_bytea) did not use PostgreSQL's connection-aware escaping functions (PQescapeStringConn/PQescapeByteaConn). The commit diff shows these functions were replaced with connection-dependent methods (e.g., connection.escape_string), and the documentation explicitly warns that the module-level functions lack connection-specific safety checks. The CVE and advisory confirm that these functions are unsafe for multi-byte encodings, making them the root cause of the SQL injection vulnerability.