PostgreSQL quoting APIs miss neutralizing quoting syntax in text that fails encoding validation
Workaround:the vendor lists a workaround. No fixed version in the CVE record. See workaround ↓
PostgreSQL's libpq escaping functions (PQescapeLiteral, PQescapeIdentifier, PQescapeString and PQescapeStringConn) and its command-line utilities fail to neutralize quoting syntax in text that fails encoding validation, which can enable SQL injection. An attacker who can supply input to the database, or control command-line arguments when client_encoding is BIG5 and server_encoding is EUC_TW or MULE_INTERNAL, can achieve SQL injection, though with the libpq functions this requires the application to pass their output into psql, and the attack is considered high complexity.
Official description · CVE.org
Improper neutralization of quoting syntax in PostgreSQL libpq functions PQescapeLiteral(), PQescapeIdentifier(), PQescapeString(), and PQescapeStringConn() allows a database input provider to achieve SQL injection in certain usage patterns. Specifically, SQL injection requires the application to use the function result to construct input to psql, the PostgreSQL interactive terminal. Similarly, improper neutralization of quoting syntax in PostgreSQL command line utility programs allows a source of command line arguments to achieve SQL injection when client_encoding is BIG5 and server_encoding is one of EUC_TW or MULE_INTERNAL. Versions before PostgreSQL 17.3, 16.7, 15.11, 14.16, and 13.19 are affected.
- Exploited
- Yes, in VulnCheck KEV
- Reports
- 0
- Tactics
- 0/15
Exploitation timelineDated milestones for a CVE: when it was disclosed, when exploit code became public, when exploitation was confirmed, and when threat reports named it.
First seen exploited the day it was disclosed. Public exploit code (Metasploit) was available 59 days before disclosure.
- Public exploit codeMetasploit59 days before
Affected versions and fixes
as published in the CVE recordPostgreSQL
Affected: >= 17, < 17.3 · >= 16, < 16.7 · >= 15, < 15.11 · >= 14, < 14.16 · < 13.19
Workaround
Confirm input passes encoding validation before quoting it.