CVE-2025-1094

Description

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.

Statement

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.

Mitigation

To mitigate, apply PostgreSQL patches once available. Until then:

1. Validate UTF-8 encoding: Reject inputs containing invalid UTF-8 sequences before passing to psql.
2. Avoid dynamic SQL: Use parameterized queries or ORM frameworks to minimize direct psql usage with raw input.
3. Restrict psql privileges: Limit OS-level permissions for the PostgreSQL user to reduce RCE impact.
4. Monitor logs: Flag repeated invalid byte sequence for encoding "UTF8" errors, which may indicate exploitation attempts.

Common Vulnerability Scoring System (CVSS) Score Details

Info alert:Important note

CVSS scores for open source components depend on vendor-specific factors (e.g. version or build chain). Therefore, Red Hat's score and impact rating can be different from NVD and other vendors. Red Hat remains the authoritative CVE Naming Authority (CNA) source for its products and services (see Red Hat classifications).

CVSS v3 Score Breakdown

Red HatNVDcve.org
Base Score8.1N/A8.1
Attack VectorNetworkN/ANetwork
Attack ComplexityHighN/AHigh
Privileges RequiredNoneN/ANone
User InteractionNoneN/ANone
ScopeUnchangedN/AUnchanged
ConfidentialityHighN/AHigh
Integrity ImpactHighN/AHigh
Availability ImpactHighN/AHigh

Vector

Red Hat: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

cve.org: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

Understanding the Weakness (CWE)

Integrity

Technical Impact: Unexpected State

Frequently Asked Questions

Want to get errata notifications? Sign up here.