/

CVE-2026-61818

Severity:

HIGH RISK

(8.5)

SQL Injection (CWE-89) in pg_partman undo_partition

CVE-2026-61818

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized SQL execution with the invoking caller's privileges

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

A SQL injection vulnerability in pg_partman's undo_partition() function allows a partman_user role to place SQL text where a function name is expected. When a caller invokes the function, the injected SQL may execute with that caller's database privileges.

Affected context

The issue occurs in pg_partman deployments prior to 5.5.0 when undo_partition() uses the part_config.time_encoder value in a dynamically constructed SELECT statement without identifier quoting. Exploitation generally depends on a role with partman_user access being able to influence that configuration value and a privileged caller subsequently invoking the affected function. The function is not normally part of the default background-worker execution path.

Exploit preconditions

  • Attack surface: PostgreSQL extension function undo_partition()
  • Required access: A role with partman_user access that can store or alter the relevant configuration value
  • Trigger point: Invocation of undo_partition() by a database role
  • Privilege condition: The invoking role must have permissions that make the resulting SQL operations consequential
  • Why exploitation is possible: Unrestricted configuration text is interpolated into dynamic SQL without safe identifier handling

Why this happens

The underlying bug is the construction of a dynamic SELECT statement from unrestricted text that is treated as a function name. Because the value is interpolated without identifier quoting or a constrained allowlist, attacker- controlled content can alter the meaning of the SQL statement. This maps to CWE-89, SQL Injection, where input crosses a query-construction boundary without sufficient separation between data and executable SQL.

Potential impact

  • A caller's database privileges may be abused to read or modify data
  • Database integrity could be affected through unauthorized SQL operations
  • Availability may be reduced through destructive or resource-intensive queries
  • Privileged callers could expose broader confidentiality, integrity, or availability permissions
  • In some deployments, database compromise could support follow-on access to connected systems

General mitigation guidance

Mitigation generally focuses on removing SQL construction from untrusted

configuration values and reducing the authority available to extension

functions.

Common defensive patterns include:

  • Restricting configuration fields to validated function identifiers or a narrowly defined allowlist
  • Using parameterized SQL for values and safe identifier-quoting mechanisms where dynamic identifiers are unavoidable
  • Separating configuration data from executable SQL fragments
  • Limiting which roles can modify partman configuration and invoke maintenance functions
  • Applying least privilege to database roles and connected application accounts
  • Reviewing existing configuration values for unexpected SQL syntax
  • Keeping extension components maintained through the organization's normal security-update process

How teams detect issues like this

Detection approaches can include:

  • Static analysis rules for string interpolation or concatenation in dynamic SQL construction
  • Code review checks for unquoted identifiers derived from table, column, function, or configuration fields
  • Database audits of roles that can modify partman configuration or execute undo_partition()
  • Monitoring configuration changes for values containing SQL operators, comments, statement separators, or unexpected keywords
  • Query logging and alerting for unusual statements executed during partition maintenance
  • Policy enforcement requiring parameterization, identifier allowlists, and privilege review for database extensions
  • Neutral automated code-review tooling to flag dynamic query construction patterns

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-fm3m-9fh7-mqfc

Frequently asked

questions

It can be exploitable through a database-facing application or administrative

workflow when an attacker can obtain the required partman_user access and

influence the relevant configuration. It is not necessarily reachable from an

unauthenticated network client.

A role with partman_user access must be able to influence the configuration,

and a caller must invoke undo_partition(). The impact depends on the

privileges of that invoking caller.

The safest pattern is to prevent configuration text from becoming executable

SQL, use parameterized statements and safe identifier handling, and constrain

accepted function names through validation or an allowlist.

Separate data from SQL syntax, audit dynamic query construction, restrict

configuration and function-execution privileges, and monitor database

maintenance operations for unexpected query behavior.

Find out what's already
exploitable in your codebase.