{"id":"CVE-2026-44477","aliases":["CVE-2026-44477","GHSA-423p-g724-fr39","GO-2026-5106"],"related":[],"kind":"vulnerability","state":"published","title":"CloudNativePG: Metrics exporter allows privilege escalation to PostgreSQL superuser and OS RCE","summary":"CloudNativePG is a platform designed to manage PostgreSQL databases within Kubernetes environments. Prior to 1.29.1 and 1.28.3, the CloudNativePG metrics exporter opens its PostgreSQL connection as the postgres superuser via the pod-local Unix socket, then demotes the session with SET ROLE pg_monitor. SET ROLE changes only current_user; session_user remains postgres. Any SQL expression evaluated inside the scrape session can invoke RESET ROLE to recover real superuser privileges, then use COPY ... TO PROGRAM to spawn an OS-level subprocess as the postgres user inside the primary pod. The READ ONLY transaction flag does not block this; it gates writes to database state, not external processes. This vulnerability is fixed in 1.29.1 and 1.28.3.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"CloudNativePG is a platform designed to manage PostgreSQL databases within Kubernetes environments. Prior to 1.29.1 and 1.28.3, the CloudNativePG metrics exporter opens its PostgreSQL connection as the postgres superuser via the pod-local Unix socket, then demotes the session with SET ROLE pg_monitor. SET ROLE changes only current_user; session_user remains postgres. Any SQL expression evaluated inside the scrape session can invoke RESET ROLE to recover real superuser privileges, then use COPY ... TO PROGRAM to spawn an OS-level subprocess as the postgres user inside the primary pod. The READ ONLY transaction flag does not block this; it gates writes to database state, not external processes. This vulnerability is fixed in 1.29.1 and 1.28.3.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nThe CloudNativePG metrics exporter opens its PostgreSQL connection as the `postgres` superuser via the pod-local Unix socket, then demotes the session with `SET ROLE pg_monitor`. `SET ROLE` changes only `current_user`; `session_user` remains `postgres`. That residual superuser identity is the foothold for the rest of the chain.\n\nAny SQL expression evaluated inside the scrape session can invoke `RESET ROLE` to recover real superuser privileges, then use `COPY ... TO PROGRAM` to spawn an OS-level subprocess as the `postgres` user inside the primary pod. The `READ ONLY` transaction flag does not block this; it gates writes to database state, not external processes.\n\nTwo exploitation paths follow from this root cause.\n\n#### Path 1: custom metric queries with unqualified identifiers (all supported releases)\n\nA database user who owns a schema on the `search_path` of any scraped database can plant a shadow object whose name matches an unqualified identifier in a custom metric query. When the exporter next evaluates that query, the shadow expression executes inside the `session_user = postgres` scrape session, giving the attacker PostgreSQL superuser privileges and OS command execution inside the primary pod within one scrape interval (≤30 s). Exploitability requires a custom metric query that contains an unqualified relation or function reference.\n\nAlthough `search_path` shadowing of unqualified identifiers is the most direct case, the underlying bug is that any expression evaluated inside the scrape session is a superuser code path. Other exploitable shapes include user-defined functions, operators or casts resolved during the scrape, joins or subqueries against user-owned tables and views, and index expressions or RLS policies on read-touched objects.\n\n#### Path 2: stock `default-monitoring.yaml` (all supported releases, no custom metrics required)\n\nThe `pg_extensions` metric shipped in `default-monitoring.yaml` used an unqualified `current_database()` call and ran against every user database (`target_databases: '*'`). Any non-superuser who owns a user database (including the default `app` role created by `bootstrap.initdb`) could shadow `current_database()` and trigger the full escalation chain against a stock CNPG deployment on the first scrape after the shadow was planted.\n\n#### Combined impact\n\nThe chain yields privilege escalation from a low-privileged database role (e.g. the default `app` role) to PostgreSQL superuser, plus arbitrary OS command execution as the `postgres` user inside the primary pod, all within one scrape interval. A web application SQL injection vulnerability in an app backed by a CNPG cluster is therefore sufficient to pivot to database-pod RCE.\n\n#### Who is impacted\n\n- All deployments on any supported release with default monitoring enabled are affected by Path 2.\n- All deployments on any supported release that use custom metric queries containing unqualified catalog references are affected by Path 1.\n- Multi-tenant platforms that allow customers to supply or influence custom metric query bodies are at the highest risk for Path 1.\n\n### Patches\n\nThree separate patches address the vulnerability.\n\n#### Patch 1: PR #10576 \"schema-qualify catalog references in default monitoring queries and documentation samples\"\n\nSchema-qualifies all unqualified `pg_catalog` function and view references in the shipped `default-monitoring.yaml` and in documentation examples. This closes Path 2 in operator-shipped configuration and removes the unqualified-identifier attack surface from all operator-shipped metric queries. Operators who clone or copy `default-monitoring.yaml` into custom monitoring `ConfigMap`s, or have copy-pasted unqualified queries elsewhere, must re-qualify those queries themselves.\n\nBackported to all currently supported releases:\n\n- **v1.29.x** (x ≥ 1)\n- **v1.28.x** (x ≥ 3)\n\n#### Patch 2: \"dedicated `cnpg_metrics_exporter` role with `pg_ident.conf` peer mapping\"\n\nIntroduces a dedicated `cnpg_metrics_exporter` PostgreSQL role (granted `pg_monitor`, no superuser privileges) and maps it in `pg_ident.conf` via peer authentication on the local Unix socket, following the same pattern already used for `cnpg_pooler_pgbouncer`. The metrics exporter connects as this role instead of `postgres`, so `session_user` is never a superuser and `RESET ROLE` has no escalation effect. This eliminates the root cause entirely.\n\nDemoting the session at the SQL level (via `SET SESSION AUTHORIZATION pg_monitor`) is not sufficient: the privilege check for `SET SESSION AUTHORIZATION` is whether the *authenticated* user is a superuser, not the current `session_user`. With the connection still authenticated as `postgres`, any SQL in the session can run `RESET SESSION AUTHORIZATION` and recover the original superuser identity. This is the same recovery primitive as `RESET ROLE`, one layer up. Only changing the authenticated user closes the loop.\n\nWith this change in place, the original chain breaks at every step: `RESET ROLE` and `RESET SESSION AUTHORIZATION` cannot recover superuser, and `COPY ... TO PROGRAM` requires a privilege `pg_monitor` does not grant. As defense in depth, the monitoring transaction also prepends `pg_catalog` to the connection's `search_path`, so unqualified catalog identifiers cannot resolve to user-planted shadow objects.\n\nThis patch changes the connection identity but not how queries are evaluated. Custom metric queries within `pg_monitor`'s scope (catalog reads, `pg_stat_*` views, settings) continue to work without modification. Queries that previously relied on superuser-level access (reading user-owned tables not granted to `cnpg_metrics_exporter`, or superuser-only catalogs such as `pg_authid` or `pg_subscription`) will fail and need explicit `GRANT` statements to `cnpg_metrics_exporter`.\n\nThe role is created and maintained with `PASSWORD NULL`; any password set out-of-band is cleared on the next reconcile, so the role cannot be authenticated by password regardless of operator pre-creation.\n\nFor replica clusters, upgrade the source primary cluster before any replica clusters that consume from it. The `cnpg_metrics_exporter` role is created on the source primary and replicates downstream; a replica cluster upgraded first will scrape against a missing role until the source primary upgrades or the role is created manually (see the monitoring documentation).\n\nThe patch will be backported to all currently supported releases:\n\n- **v1.29.x** (x ≥ 1)\n- **v1.28.x** (x ≥ 3)\n\n### Workarounds\n\nIf upgrading immediately is not possible:\n\n1. **Schema-qualify all identifiers in custom metric queries.** Use explicit `pg_catalog.` prefixes for all catalog functions and views (e.g. `pg_catalog.current_database()`, `pg_catalog.now()`). This is a partial mitigation: it closes the `search_path`-shadowing shape in operator- and user-supplied metric bodies, but other expression shapes (user-defined functions, operators or casts; joins or subqueries on user-owned tables and views; RLS policies on read-touched objects) remain superuser code paths until Patch 2 lands.\n\n2. **Restrict database ownership.** Ensure only fully trusted roles own user databases in scraped clusters. The exploit requires the ability to plant an object on the metrics exporter's `search_path` in a scraped database, typically by owning the database (and therefore `public` via `pg_database_owner`) or by holding `CREATE` on a schema already reachable through `search_path`.\n\n    *PG <15 caveat:* `public` grants `CREATE` to `PUBLIC` by default before PostgreSQL 15, so any authenticated role in a scraped database can plant a shadow object regardless of ownership.\n\n3. **Limit the scope of `target_databases: '*'` queries.** Avoid `target_databases: '*'` unless every database in the cluster, and every role that owns one, is fully trusted. Where possible, restrict `target_databases` to specific, known-safe databases.\n\n4. **Do not expose metric query SQL to untrusted users.** Multi-tenant platforms that allow customers to supply or influence custom metric query bodies should treat this as a critical trust boundary until the architectural fix is released.\n\n### References\n\n- Fix (Patch 1): PR #10576 \"schema-qualify catalog references in default monitoring queries and documentation samples\"\n- Fix (Patch 2): \"dedicated `cnpg_metrics_exporter` role with `pg_ident.conf` peer mapping\"\n- Reported by: Mehmet Ince","format":"markdown","source":"ghsa"},{"lang":"en","text":"CloudNativePG's metrics exporter allows privilege escalation to PostgreSQL superuser and OS RCE in github.com/cloudnative-pg/cloudnative-pg","format":"markdown","source":"go"}],"published":"2026-05-11T15:59:12.000Z","modified":"2026-09-10T03:50:45.436Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","score":9.4,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","score":9.4,"rating":"CRITICAL"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":9.9,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":9.9,"rating":"CRITICAL"}],"cwes":["CWE-250","CWE-271","CWE-426"],"affected":[{"ranges":[{"version":"< 1.28.3","status":"affected"},{"version":">= 1.29.0, < 1.29.1","status":"affected"}],"vendor":"cloudnative-pg","product":"cloudnative-pg","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/devicefinder-rhel9","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/mcg-rhel9-operator","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/ocs-metrics-exporter-rhel9","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/ocs-rhel9-operator","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/odf-cli-rhel9","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/odf-cloudnative-pg-rhel9-operator","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/odf-multicluster-rhel9-operator","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Openshift Data Foundation 4","package":"odf4/odf-rhel9-operator","cpe":"cpe:/a:redhat:openshift_data_foundation:4","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.28.3"}],"ecosystem":"Go","package":"github.com/cloudnative-pg/cloudnative-pg","purl":"pkg:golang/github.com/cloudnative-pg/cloudnative-pg","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"1.29.0","status":"affected","fixed":"1.29.1"}],"ecosystem":"Go","package":"github.com/cloudnative-pg/cloudnative-pg","purl":"pkg:golang/github.com/cloudnative-pg/cloudnative-pg","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.28.3"},{"type":"semver","introduced":"1.29.0","status":"affected","fixed":"1.29.1"}],"ecosystem":"Go","package":"github.com/cloudnative-pg/cloudnative-pg","purl":"pkg:golang/github.com/cloudnative-pg/cloudnative-pg","source":"go"},{"ranges":[{"status":"affected","fixed":"1.28.3"},{"status":"affected","introduced":"1.29.0","fixed":"1.29.1"}],"vendor":"linuxfoundation","product":"cloudnativepg","cpe":"cpe:2.3:a:linuxfoundation:cloudnativepg:*:*:*:*:*:kubernetes:*:*","source":"nvd"}],"references":[{"url":"https://github.com/cloudnative-pg/cloudnative-pg/security/advisories/GHSA-423p-g724-fr39","tags":["advisory","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/cloudnative-pg/cloudnative-pg/pull/10576","tags":["fix","issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-44477","tags":["vdb-entry","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2482763","tags":["issue-tracking","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-44477.json","tags":["x-sadp-csaf-vex"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-44477","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/cloudnative-pg/cloudnative-pg","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/cloudnative-pg/cloudnative-pg/releases/tag/v1.28.3","tags":["web"],"sources":["ghsa","go"]},{"url":"https://github.com/cloudnative-pg/cloudnative-pg/releases/tag/v1.29.1","tags":["web"],"sources":["ghsa","go"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-05-28T17:28:36.663Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-44477","url":"https://www.cve.org/CVERecord?id=CVE-2026-44477","licence":"CVE Terms of Use","modified":"2026-07-15T00:54:01.418Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-423p-g724-fr39","url":"https://github.com/advisories/GHSA-423p-g724-fr39","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:45.436Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5106","url":"https://pkg.go.dev/vuln/GO-2026-5106","licence":"CC-BY-4.0","modified":"2026-06-25T18:45:20.861Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-44477","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-44477","licence":"Public domain","modified":"2026-07-15T02:21:54.357Z"}],"updatedAt":"2026-11-25T22:59:22.958Z","epss":{"score":0.00515,"percentile":0.37164,"date":"2026-11-30T12:00:22.000Z"}}