From eaecde82ad3d1518e6b0fefef7d16c02bf4a1053 Mon Sep 17 00:00:00 2001 From: Andrey Kolkov Date: Thu, 26 Nov 2026 16:17:35 +0700 Subject: [PATCH] fix(postgres): move tenant PostgreSQL to patched standard-trixie images The chart pinned bare image tags, which are the system variant on Debian bullseye. Upstream stopped building that variant, so the minors that fix CVE-2026-116331 (18.7, 17.12, 16.16, 15.20, 14.25) are published for bookworm and trixie only. The CVE is a type confusion in the min/max aggregate optimisation that lets a role able to create objects run code as the operating system user of the server, and tenants hold such roles. Pin the patched minors on standard-trixie. The standard variant, because backups go through the barman-cloud plugin and need none of the barman binaries the system variant adds. trixie, because main is on it and release-1.7 moves to it with the backport batch that carries this change, so a 1.6 cluster that upgrades to such a 1.7 release does not move its Debian release a second time. PostgreSQL 13 has no patched release: it keeps 13.22 and moves to trixie with the rest. For a running cluster this changes the Debian release under the data directory. The init Job rebuilds the indexes that depend on a collation whose library version changed. release-1.6 has no postgis flavor, so its version map, its unit test and the flavor guard are not carried over, and postgres.imageName has only the postgresql branch. (cherry picked from commit b40be51a6b3dc521d28ed06f7603a32f01a88955) Assisted-By: LLM Signed-off-by: Andrey Kolkov --- packages/apps/postgres/files/versions.yaml | 10 +++++----- packages/apps/postgres/hack/update-versions.sh | 5 +++-- packages/apps/postgres/templates/_versions.tpl | 13 +++++++++++++ packages/apps/postgres/templates/db.yaml | 10 ++++------ packages/apps/postgres/templates/init-job.yaml | 2 +- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/apps/postgres/files/versions.yaml b/packages/apps/postgres/files/versions.yaml index e4fe13ead..2624066e3 100644 --- a/packages/apps/postgres/files/versions.yaml +++ b/packages/apps/postgres/files/versions.yaml @@ -1,6 +1,6 @@ -"v18": "v18.1" -"v17": "v17.7" -"v16": "v16.11" -"v15": "v15.15" -"v14": "v14.20" +"v18": "v18.7" +"v17": "v17.12" +"v16": "v16.16" +"v15": "v15.20" +"v14": "v14.25" "v13": "v13.22" diff --git a/packages/apps/postgres/hack/update-versions.sh b/packages/apps/postgres/hack/update-versions.sh index c92b3895b..8567402a8 100755 --- a/packages/apps/postgres/hack/update-versions.sh +++ b/packages/apps/postgres/hack/update-versions.sh @@ -32,9 +32,10 @@ if ! command -v jq &> /dev/null; then exit 1 fi -# Get available image tags +# Get available image tags. Only standard-trixie builds count: the chart +# appends that suffix to the minor it reads from versions.yaml. echo "Fetching available image tags from registry..." -AVAILABLE_TAGS=$(skopeo list-tags docker://ghcr.io/cloudnative-pg/postgresql | jq -r '.Tags[] | select(test("^[0-9]+\\.[0-9]+$"))' | sort -V) +AVAILABLE_TAGS=$(skopeo list-tags docker://ghcr.io/cloudnative-pg/postgresql | jq -r '.Tags[] | select(test("^[0-9]+\\.[0-9]+-standard-trixie$")) | sub("-standard-trixie$"; "")' | sort -V) if [ -z "$AVAILABLE_TAGS" ]; then echo "Error: Could not fetch available image tags" >&2 diff --git a/packages/apps/postgres/templates/_versions.tpl b/packages/apps/postgres/templates/_versions.tpl index ca0ff2a27..e81086303 100644 --- a/packages/apps/postgres/templates/_versions.tpl +++ b/packages/apps/postgres/templates/_versions.tpl @@ -6,3 +6,16 @@ {{- index $versionMap .Values.version }} {{- end }} +{{/* + Single source for the operand image: the init Job runs psql against the + Cluster, so both must resolve the same image, and the Job compares its own + PostgreSQL build with the server's to tell when a new image has rolled out. + + standard-trixie, not the bare tag: a bare tag is the system variant on + Debian bullseye, which upstream stopped building. The standard variant, + because backups go through the barman-cloud plugin and need none of the + barman binaries the system variant adds. +*/}} +{{- define "postgres.imageName" -}} +ghcr.io/cloudnative-pg/postgresql:{{ include "postgres.versionMap" . | trim | trimPrefix "v" }}-standard-trixie +{{- end -}} diff --git a/packages/apps/postgres/templates/db.yaml b/packages/apps/postgres/templates/db.yaml index 9cfb93def..a6a05b59a 100644 --- a/packages/apps/postgres/templates/db.yaml +++ b/packages/apps/postgres/templates/db.yaml @@ -107,11 +107,9 @@ spec: The S3/barman settings live in the barmancloud.cnpg.io/ObjectStore CR rendered at the bottom of this file (named after the release); the Cluster only references it by name. Native spec.backup.barmanObjectStore - is deprecated in CNPG 1.27 and removed in 1.29. The bare (system-flavor) - image tags this chart pins still ship the barman-cloud-* binaries the - native path needs (unlike the `standard` variant keycloak-db pins), but - the system flavor is deprecated upstream, so this chart moves to the - plugin as well. + is deprecated in CNPG 1.27 and removed in 1.29, and the standard image + variant this chart pins does not ship the barman-cloud-* binaries the + native path needs; the plugin runs them in a sidecar. */}} {{- $hasInlineCreds := and (ne (default "" .Values.backup.s3AccessKey) "") (ne (default "" .Values.backup.s3SecretKey) "") }} {{- $hasLegacyCreds := or $hasInlineCreds (ne (default "" $credCfg.name) "") }} @@ -213,7 +211,7 @@ spec: resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 4 }} - imageName: ghcr.io/cloudnative-pg/postgresql:{{ include "postgres.versionMap" $ | trimPrefix "v" }} + imageName: {{ include "postgres.imageName" $ }} enableSuperuserAccess: true {{- if .Values._cluster.scheduling }} {{- $rawConstraints := get .Values._cluster.scheduling "globalAppTopologySpreadConstraints" }} diff --git a/packages/apps/postgres/templates/init-job.yaml b/packages/apps/postgres/templates/init-job.yaml index 7d99c36c9..af8c89af4 100644 --- a/packages/apps/postgres/templates/init-job.yaml +++ b/packages/apps/postgres/templates/init-job.yaml @@ -47,7 +47,7 @@ spec: restartPolicy: Never containers: - name: postgres - image: ghcr.io/cloudnative-pg/postgresql:{{ include "postgres.versionMap" $ | trimPrefix "v" }} + image: {{ include "postgres.imageName" $ }} command: - bash - /scripts/init.sh