/

CVE-2026-61819

Severity:

HIGH RISK

(8.5)

SQL Injection (CWE-89) in pg_partman Job Monitoring

CVE-2026-61819

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

pg_partman contains a SQL injection vulnerability in exception-handling paths that pass a parent-table name into a SQL string used by pg_jobmon. If a user who can create or control a partitioned-table name causes an affected maintenance path to run, injected SQL may execute with the privileges of the background worker, potentially including database-wide administrative access and operating-system command execution.

Affected context

The issue occurs in pg_partman deployments where pg_jobmon is installed and the relevant part_config.jobmon setting is enabled. It requires a partman_user or another suitably privileged database principal to establish a parent-table name containing SQL-significant characters, followed by execution of an affected exception path. Risk is greatest when pg_partman_bgw runs with highly privileged PostgreSQL credentials, such as a superuser role.

Exploit preconditions

  • Attack surface: PostgreSQL extension functions and background maintenance processing
  • Required access: Ability to create or register a partitioned parent table whose name is later used by pg_partman
  • Trigger point: An affected pg_partman exception handler invokes pg_jobmon.add_job()
  • Required configuration: pg_jobmon is installed and part_config.jobmon is enabled
  • Why exploitation is possible: The parent-table name is inserted verbatim into a SQL string literal without adequate parameterization or escaping
  • Privilege condition: The resulting statements execute with the privileges assigned to pg_partman_bgw, which may include PostgreSQL superuser privileges

Why this happens

The underlying bug is SQL injection caused by concatenating identifier-derived data into a dynamically constructed SQL string literal. A single quote in the parent-table name can alter the intended literal boundaries and change the meaning of the generated statement when the exception path executes. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, because input is incorporated into SQL without a safe separation between data and executable command structure.

Potential impact

  • An attacker may execute unauthorized SQL statements within the database
  • Database contents, schemas, roles, or security controls could be modified
  • The attacker could obtain or alter data across database-wide scopes
  • The background worker process could be abused to execute operating-system commands
  • The PostgreSQL service account and connected application data could be compromised
  • Persistent configuration may allow the malicious condition to recur during later maintenance cycles

General mitigation guidance

Mitigation generally focuses on preserving the boundary between identifiers, values, and executable SQL.

Common defensive patterns include:

  • Using parameterized SQL or trusted identifier-quoting APIs rather than string concatenation
  • Treating table names and other database metadata as untrusted input at every function boundary
  • Restricting who may create or register partitioned parent tables
  • Running background maintenance roles with only the permissions required for their tasks
  • Separating job-monitoring privileges from database-administration and operating-system execution privileges
  • Limiting persistence and mutability of partition-management configuration
  • Reviewing exception paths as carefully as normal execution paths
  • Applying database allowlisting and auditing controls for dynamic SQL operations

How teams detect issues like this

Detection can combine source review, runtime monitoring, and privilege analysis:

  • Static analysis can flag concatenation of table names or other external data into SQL strings
  • Code review should examine exception handlers, logging or job-reporting calls, and dynamic SQL construction
  • Repository policies can require parameterized statements or approved identifier-quoting helpers
  • Database auditing can monitor unexpected DDL, role changes, privileged statements, and operating-system command interfaces
  • Configuration reviews can identify background workers operating with superuser or otherwise excessive privileges
  • Automated security review tools may help identify unsafe dynamic SQL patterns before deployment

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-gv5h-j2cm-rhc3

Frequently asked

questions

Exploitability depends on the PostgreSQL exposure and the permissions granted to database users. It is not necessarily reachable by an unauthenticated network attacker, but a user able to create or control the relevant parent-table metadata may be able to establish the condition.

The key requirement is database access sufficient to create or register a partitioned parent table whose name is processed by pg_partman. The impact also depends on the privileges assigned to the pg_partman background worker.

The safest pattern is to ensure that all dynamic SQL separates data and identifiers from executable SQL, using parameterization or trusted identifier-quoting mechanisms. Excessive background-worker privileges should also be removed where operationally possible.

Treat object names as untrusted input, review error-handling and monitoring paths for dynamic SQL, enforce secure coding policies, and audit database roles and persistent maintenance configuration.

Find out what's already
exploitable in your codebase.