FreeBSD VuXML: Documenting security issues in FreeBSD and the FreeBSD Ports Collection

postgresql -- encoding based SQL injection

Affected packages
7.3 <= ja-postgresql < 7.3.15
7.4 <= ja-postgresql < 7.4.13
8.0.0 <= ja-postgresql < 8.0.8
8.1.0 <= ja-postgresql < 8.1.4
7.3 <= postgresql < 7.3.15
7.4 <= postgresql < 7.4.13
8.0.0 <= postgresql < 8.0.8
8.1.0 <= postgresql < 8.1.4
7.3 <= postgresql-server < 7.3.15
7.4 <= postgresql-server < 7.4.13
8.0.0 <= postgresql-server < 8.0.8
8.1.0 <= postgresql-server < 8.1.4

Details

VuXML ID 17f53c1d-2ae9-11db-a6e2-000e0c2e438a
Discovery 2006-05-11
Entry 2006-08-13

The PostgreSQL development team reports:

An attacker able to submit crafted strings to an application that will embed those strings in SQL commands can use invalidly-encoded multibyte characters to bypass standard string-escaping methods, resulting in possible injection of hostile SQL commands into the database. The attacks covered here work in any multibyte encoding.

The widely-used practice of escaping ASCII single quote "'" by turning it into "\'" is unsafe when operating in multibyte encodings that allow 0x5c (ASCII code for backslash) as the trailing byte of a multibyte character; this includes at least SJIS, BIG5, GBK, GB18030, and UHC. An application that uses this conversion while embedding untrusted strings in SQL commands is vulnerable to SQL-injection attacks if it communicates with the server in one of these encodings. While the standard client libraries used with PostgreSQL have escaped "'" in the safe, SQL-standard way of "''" for some time, the older practice remains common.

References

Bugtraq ID 18092
CVE Name CVE-2006-2313
CVE Name CVE-2006-2314
URL http://www.postgresql.org/docs/techdocs.50