CVE-2009-2940 PyGreSQL Might Be Vulnerable to Encoding-Based SQL Injection

High 7.5 Published Updated

Remote attackers can exploit improper string escaping in the pygresql module to perform SQL injection attacks, potentially reading or modifying database contents.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2009-2940?

CVE-2009-2940 is a high-severity SQL injection vulnerability in n/a, published on 22 Oct 2009. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official 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.

Which versions are affected by CVE-2009-2940?

5 open source packages ship an affected version, including pygresql and PyGreSQL. It affects 1 product.

PackageAffectedFixed in
pygresql PyPIAll versions to 3.8.1None
pygresql PyPIFrom 3.8.1 to 4.0None
pygresql PyPIFrom 4.04.1
PyGreSQL PyPIAll versions to 3.8.1None
PyGreSQL PyPIFrom 4.04.1

Products include Pygresql Pygresql.

How do I fix CVE-2009-2940?

Upgrade pygresql to 4.1 or later.

Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.

Is CVE-2009-2940 being exploited?

There is no known exploitation of CVE-2009-2940 in the wild and no public exploit code.

Sources

Also known as DEBIAN-CVE-2009-2940, DSA-1911-1, GHSA-xv6x-43gq-4hfj, PYSEC-2009-18.

Is CVE-2009-2940 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free