/

CVE-2026-61817

Severity:

HIGH RISK

(8.5)

SQL Injection (CWE-89) in pg_partman SQL Functions API

CVE-2026-61817

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database and Operating System Command Execution

Severity:

HIGH RISK

(8.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

CVE-2026-61817 is a high-severity SQL injection vulnerability in pg_partman, where writable decoder configuration text is inserted into dynamic SQL without identifier quoting. A role with documented partman_user privileges may persist SQL that executes when maintenance or partition-management functions later process the poisoned value, potentially reaching database-wide compromise and operating-system command execution.

Affected context

The vulnerability occurs in pg_partman deployments using affected versions before 5.5.0 when the writable part_config.time_decoder value is used by dynamic-SQL operations such as run_maintenance(), show_partitions(), show_partition_info(), undo_partition(), or partition_data_time(). Risk is higher for text- or UUID-keyed partition sets and environments where the pg_partman background worker runs with highly privileged PostgreSQL credentials.

Exploit preconditions

  • Attack surface: PostgreSQL extension functions and scheduled pg_partman background-worker maintenance
  • Required access: A database role with the documented privileges that permit writing the relevant partman configuration value
  • Trigger point: Affected partition-management or maintenance functionality later consumes the stored decoder value
  • Why exploitation is possible: The value is interpolated into dynamic SQL without appropriate identifier quoting or strict validation, allowing stored SQL to be interpreted as executable syntax
  • Privilege condition: The resulting statements execute with the privileges of the invoking operation, which may include a PostgreSQL superuser background-worker role

Why this happens

The underlying bug is a dynamic SQL construction flaw mapped to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'). A writable configuration field intended to contain a decoder function name is treated as trusted SQL text and concatenated into statements without safely representing it as an identifier or restricting it to an approved value. Because the malicious value is persistent, later maintenance operations can repeatedly interpret it with their own database privileges.

Potential impact

  • Unauthorized execution of SQL with the maintenance operation's privileges
  • Database-wide data disclosure, modification, or destruction
  • Creation or alteration of privileged database objects
  • Persistence through poisoned configuration rows and future maintenance cycles
  • Operating-system command execution through PostgreSQL capabilities or trusted extensions
  • Compromise of the PostgreSQL service account and dependent applications

General mitigation guidance

Mitigation generally focuses on removing executable interpretation from configuration data and reducing the privileges available to maintenance processes.

Common defensive patterns include:

  • Representing decoder functions with validated, schema-qualified identifiers rather than raw SQL fragments
  • Using safe identifier-quoting APIs and parameterized values when constructing dynamic SQL
  • Allowing only explicitly approved decoder functions through an allowlist
  • Treating partman configuration rows as protected metadata with narrowly scoped write permissions
  • Running background workers with a dedicated least-privileged database role
  • Separating maintenance privileges from roles that can create functions, access sensitive data, or invoke operating-system functionality
  • Reviewing and remediating existing configuration records for unexpected decoder values
  • Applying database policies that restrict extension functions and dynamic-code capabilities

How teams detect issues like this

Detection approaches may include:

  • Static analysis rules for string concatenation or formatting used to build SQL statements
  • Code review checks for configuration fields inserted into dynamic SQL without identifier quoting
  • Database queries that inventory part_config decoder values and compare them against approved function names
  • Audit logging for changes to partman configuration tables and execution of maintenance functions
  • Alerts for background-worker activity involving unexpected object creation, privilege changes, or unusual SQL statements
  • Policy enforcement requiring parameterized SQL, safe identifier APIs, and allowlisted function references
  • Automated security review tools that flag stored configuration data crossing into executable SQL contexts

Sources

SourceLink
github.comgithub.com/pgpartman/pg_partman/commit/ba9405542acf24dd881845b935cab8b165854361
github.comgithub.com/pgpartman/pg_partman/releases/tag/v5.5.0
github.comgithub.com/pgpartman/pg_partman/security/advisories/GHSA-gmw2-52wc-258g

Frequently asked

questions

Exploitation is generally conditional rather than unauthenticated. An attacker must first obtain database access and the privileges needed to modify the relevant pg_partman configuration value.

Potentially. A role with the documented partman_user privileges may be able to store the poisoned value, while later execution can occur with the greater privileges of a maintenance operation or background worker.

Ensure configuration values are treated as data, not SQL. Validate decoder references against an allowlist and use proper identifier-quoting or safe dynamic-SQL APIs for any unavoidable identifier interpolation.

Minimize write access to extension metadata, use least-privileged maintenance roles, review dynamic SQL construction, audit persistent configuration changes, and enforce automated checks for untrusted data entering executable SQL.

Find out what's already
exploitable in your codebase.