/

CVE-2026-61821

Severity:

HIGH RISK

(8.5)

Missing Authorization (CWE-862) in pg_partman PostgreSQL

CVE-2026-61821

Awaiting Analysis

Vulnerability type

Category:

Missing Authorization

CWE:

CWE-862

Impact:

Unauthorized schema and table relocation

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

pg_partman allows a role with partman_user access to request relocation of retained child tables into a schema where that role would not normally have CREATE privileges. Because the background worker performs the operation with its configured role privileges, the authorization boundary may be bypassed and tables may be moved between schemas without proper permission.

Affected context

The issue occurs in pg_partman deployments where the retention configuration supplies a nonempty target schema for partition cleanup operations. It is relevant when drop_partition_id() or drop_partition_time() are invoked through the background worker and that worker operates with privileges greater than those of the requesting partman_user role.

Exploit preconditions

  • Attack surface: pg_partman partition-retention functions and their background-worker execution path
  • Required access: A database role with partman_user access and the ability to influence or invoke the relevant retention operation
  • Trigger point: Execution of drop_partition_id() or drop_partition_time() using a configured retention schema
  • Why exploitation is possible: The target schema is accepted when nonempty, while the relocation is performed with background-worker privileges rather than the requesting role's normal authorization context

Why this happens

The underlying flaw is an authorization-context mismatch in schema relocation. pg_partman uses the configured retention_schema as the destination for ALTER TABLE SET SCHEMA without ensuring that the requesting role is authorized to create objects or perform the corresponding relocation in that schema.

This maps to CWE-862: Missing Authorization, because a privileged execution path performs a state-changing database operation without adequately enforcing the permissions that would apply to the initiating role.

Potential impact

  • Unauthorized relocation of retained child tables between schemas
  • Exposure of tables to users or applications with access to the destination schema
  • Disruption of schema-based access-control assumptions
  • Possible data governance, isolation, or availability impacts

General mitigation guidance

Mitigation generally focuses on preserving the initiating role's authorization boundary and restricting schema relocation targets.

Common defensive patterns include:

  • Enforcing explicit authorization checks for the requesting role before changing table schemas
  • Allowing only approved, policy-controlled retention schemas
  • Avoiding execution of user-influenced DDL under broad superuser privileges
  • Running background workers with the minimum database privileges required
  • Separating retention maintenance permissions from general schema-management permissions
  • Auditing schema changes and retaining an immutable record of the initiating identity and target schema

How teams detect issues like this

Organizations can detect this class of issue through:

  • Static analysis and code review checks for privileged DDL executed on behalf of less-privileged roles
  • Review of functions that use configured schema names as dynamic ALTER TABLE SET SCHEMA targets
  • Database audit logging for schema changes performed by background-worker or superuser identities
  • Policy checks requiring explicit allowlists for maintenance destinations
  • Tests that compare the permissions of the initiating role with those used by asynchronous workers
  • Monitoring for unexpected movement of partition child tables across schema boundaries

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-pxp2-x8cf-rfhc

Frequently asked

questions

Exploitation generally requires a database role with partman_user access and a way to invoke or influence the affected partition-retention operation.

The described behavior specifically enables unauthorized relocation of retained child tables between schemas. The broader impact depends on the privileges associated with the destination schema and the background worker.

Ensure that schema relocation is authorized for the initiating role, restrict destination schemas through explicit policy, and avoid performing user-influenced DDL with unnecessary superuser privileges.

Treat asynchronous workers as separate privilege boundaries, test authorization under both caller and worker identities, audit privileged DDL, and enforce allowlists for configuration values that affect object placement.

Find out what's already
exploitable in your codebase.