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_configdecoder 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

