diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 458fc6d..c3b9b76 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -79,7 +79,8 @@ jobs: cache-to: type=gha,mode=max # Gate: a build whose PostGIS is vulnerable to CVE-2026-73514 / - # CVE-2026-73515 must never reach a tag. The PR job runs it on the loaded + # CVE-2026-73515, or whose server predates 18.7 (CVE-2026-6460), must + # never reach a tag. The PR job runs it on the loaded # image; the push job below runs it on the pushed digest before the # manifest job can move `latest`/`18` onto it. - name: Verify PostGIS security (PR, amd64) @@ -90,6 +91,7 @@ jobs: docker run -d --name postgis-verify -e POSTGRES_PASSWORD=test "$tag" until docker exec postgis-verify pg_isready -U postgres -q; do sleep 1; done ./scripts/verify-postgis-security.sh postgis-verify + ./scripts/verify-postgres-security.sh postgis-verify - name: Build & push by digest if: github.event_name != 'pull_request' @@ -114,6 +116,7 @@ jobs: docker run -d --name postgis-verify -e POSTGRES_PASSWORD=test "$image" until docker exec postgis-verify pg_isready -U postgres -q; do sleep 1; done ./scripts/verify-postgis-security.sh postgis-verify + ./scripts/verify-postgres-security.sh postgis-verify - name: Export digest if: github.event_name != 'pull_request' diff --git a/Makefile b/Makefile index 5ead4b2..fa2eb91 100644 --- a/Makefile +++ b/Makefile @@ -42,13 +42,15 @@ test: build CREATE EXTENSION pg_partman; \ SELECT 'all extensions OK';" @./scripts/verify-postgis-security.sh $(CONTAINER_NAME)-test + @./scripts/verify-postgres-security.sh $(CONTAINER_NAME)-test @docker stop $(CONTAINER_NAME)-test > /dev/null @docker rm $(CONTAINER_NAME)-test > /dev/null # Assert the running $(CONTAINER_NAME) is not a PostGIS build vulnerable to -# CVE-2026-73514 / CVE-2026-73515. +# CVE-2026-73514 / CVE-2026-73515, nor a server older than 18.7 (CVE-2026-6460). verify-security: @./scripts/verify-postgis-security.sh $(CONTAINER_NAME) + @./scripts/verify-postgres-security.sh $(CONTAINER_NAME) clean: stop docker rmi $(IMAGE_NAME):$(IMAGE_TAG) || true diff --git a/README.md b/README.md index 23f4932..3429b8d 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,20 @@ on the pushed digest before the `latest`/`18` manifests move. Drop the patches when a PostGIS release contains all four fixes; the gate's `POSTGIS_MIN_VERSION` floor and manifest check are what to update then. +## PostgreSQL security floor + +The base image is `postgres:18-alpine`, so each build takes the newest 18.x +minor and compiles every extension from source against it. 18.7 (CVE-2026-6460 +and the rest of the 2026-11-12 release) changed the server ABI: an extension +built against 18.6 fails to load on 18.7 with `undefined symbol`, which is why +the extensions are never copied in prebuilt. + +`scripts/verify-postgres-security.sh ` is the gate: it fails when the +running server is below `server_version_num` 180007, when the +`composite_type_mismatch` check that fix added is missing or not `error`, and +when any bundled extension does not load. CI runs it next to the PostGIS gate. +Raise `PG_MIN_VERSION_NUM` when a later minor is the floor. + ## Building manually ```bash diff --git a/scripts/verify-postgres-security.sh b/scripts/verify-postgres-security.sh new file mode 100755 index 0000000..3788898 --- /dev/null +++ b/scripts/verify-postgres-security.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Fails if the image's PostgreSQL server predates the 18.7 security release +# (CVE-2026-6460 and the other fixes shipped with it). +# +# The base image is the floating `postgres:18-alpine` tag, so a rebuild picks up +# whatever minor that tag points at; this asserts against the *running* server, +# not the Dockerfile ARG. `composite_type_mismatch` is the server parameter the +# CVE-2026-6460 fix introduced, so its presence proves that fix is compiled in. +# +# Usage: verify-postgres-security.sh +set -euo pipefail + +container="${1:?usage: verify-postgres-security.sh }" +psql() { docker exec -i "$container" psql -U postgres -X -q -At "$@"; } + +# 18.7 — lowest minor carrying the 2026-11-12 security fixes. +PG_MIN_VERSION_NUM="${PG_MIN_VERSION_NUM:-180007}" + +fail() { echo "FAIL: $*" >&2; exit 1; } +ok() { echo "ok: $*"; } + +version_num="$(psql -c 'SHOW server_version_num')" +[ "$version_num" -ge "$PG_MIN_VERSION_NUM" ] \ + || fail "server_version_num $version_num is below the patched floor $PG_MIN_VERSION_NUM" +ok "postgres $(psql -c 'SHOW server_version') >= $PG_MIN_VERSION_NUM" + +mismatch="$(psql -c 'SHOW composite_type_mismatch' 2>&1)" \ + || fail "composite_type_mismatch is unknown — server lacks the CVE-2026-6460 fix" +[ "$mismatch" = "error" ] || fail "composite_type_mismatch is '$mismatch', expected 'error'" +ok "composite_type_mismatch = error (CVE-2026-6460 check active)" + +# Every C extension must load against this server's ABI: an extension built +# against an older minor fails here with "undefined symbol". +for ext in vector postgis pg_textsearch pg_partman pg_stat_statements; do + psql -c "CREATE EXTENSION IF NOT EXISTS $ext" >/dev/null || fail "CREATE EXTENSION $ext failed" +done +ok "vector, postgis, pg_textsearch, pg_partman, pg_stat_statements load" + +echo "PostgreSQL security verification passed"