Описание
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.
A flaw was found in PostgreSQL. Due to improper neutralization of quoting syntax, affected versions potentially allow a database input provider to achieve SQL injection in certain usage patterns. Specifically, SQL injection requires the application to use the affected function's 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
.
Отчет
This vulnerability is marked as Important because it not only enables SQL injection but also allows arbitrary code execution (ACE) through PostgreSQL’s psql interactive tool. The flaw arises from improper neutralization of malformed UTF-8 sequences, which can bypass PostgreSQL’s escaping functions, leading to successful injection attacks. What elevates its severity is psql's support for meta-commands, specifically the ! command, which allows execution of arbitrary shell commands on the host system. Even when untrusted input is correctly escaped (e.g., via pg_escape_string), an attacker can craft invalid UTF-8 characters containing raw bytes like 0x27 (a single quote), causing psql to misinterpret the SQL statement’s structure. This allows splitting a single query into multiple statements, enabling unauthenticated attackers to execute arbitrary SQL meta-commands (e.g., ! ) or inject malicious SQL.
Меры по смягчению последствий
To mitigate, apply PostgreSQL patches once available. Until then:
- Validate UTF-8 encoding: Reject inputs containing invalid UTF-8 sequences before passing to psql.
- Avoid dynamic SQL: Use parameterized queries or ORM frameworks to minimize direct psql usage with raw input.
- Restrict psql privileges: Limit OS-level permissions for the PostgreSQL user to reduce RCE impact.
- Monitor logs: Flag repeated invalid byte sequence for encoding "UTF8" errors, which may indicate exploitation attempts.
Затронутые пакеты
Платформа | Пакет | Состояние | Рекомендация | Релиз |
---|---|---|---|---|
Red Hat Enterprise Linux 10 | libpq | Not affected | ||
Red Hat Enterprise Linux 10 | postgresql16 | Not affected | ||
Red Hat Enterprise Linux 6 | postgresql | Out of support scope | ||
Red Hat Enterprise Linux 7 Extended Lifecycle Support | postgresql | Fixed | RHSA-2025:3978 | 17.04.2025 |
Red Hat Enterprise Linux 8 | postgresql | Fixed | RHSA-2025:1736 | 20.02.2025 |
Red Hat Enterprise Linux 8 | libpq | Fixed | RHSA-2025:1737 | 20.02.2025 |
Red Hat Enterprise Linux 8 | postgresql | Fixed | RHSA-2025:1739 | 20.02.2025 |
Red Hat Enterprise Linux 8 | postgresql | Fixed | RHSA-2025:1740 | 20.02.2025 |
Red Hat Enterprise Linux 8 | postgresql | Fixed | RHSA-2025:3082 | 20.03.2025 |
Red Hat Enterprise Linux 8.2 Advanced Update Support | libpq | Fixed | RHSA-2025:1720 | 20.02.2025 |
Показывать по
Ссылки на источники
Дополнительная информация
Статус:
EPSS
8.1 High
CVSS3
Связанные уязвимости
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.
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.
Improper neutralization of quoting syntax in PostgreSQL libpq function ...
EPSS
8.1 High
CVSS3