Skip to content

ci: block publishing a PostgreSQL server below 18.7 (CVE-2026-6460) - #18

Merged
pyramation merged 1 commit into
mainfrom
feat/postgres-18.7
Nov 13, 2026
Merged

pyramation merged 1 commit into
mainfrom
feat/postgres-18.7

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

The published postgres-plus:18 is still PostgreSQL 18.6 (built 2026-10-13). postgres:18-alpine moved to 18.7 on 2026-11-12, which fixes CVE-2026-6460 and ~50 other CVEs. The Dockerfile doesn't need to change: it builds from the floating postgres:18-alpine tag and compiles every extension from source against it. This PR adds a gate, and merging it to main rebuilds and republishes latest/18 on 18.7.

scripts/verify-postgres-security.sh <container> runs next to the PostGIS gate (PR build + pushed digest, make test, make verify-security). It fails when:

  • server_version_num < 180007
  • composite_type_mismatch is missing or not error. The CVE-2026-6460 fix added this setting, so if it's missing, the fix isn't in the server.
  • one of vector, postgis, pg_textsearch, pg_partman, pg_stat_statements won't load. 18.7 changed the server ABI, so an extension built against 18.6 fails to load with undefined symbol.

No extension version bumps are needed. pgvector 0.8.2, PostGIS 3.6.4 (+patches), pg_textsearch 1.5.1 and pg_partman 5.4.3 all build and run on 18.7. None of them is pgrx-based or on the list of affected extensions in the upstream commit message. The PostGIS issue it mentions (trac #6142) only affects upgrades from PostGIS < 3.6.

Checked locally on an image built from this Dockerfile with 18.7:

  • gate passes on that image, and fails on the current constructiveio/postgres-plus:18 (server_version_num 180006 is below the patched floor 180007)
  • PostGIS gate passes
  • smoke queries pass: HNSW, BM25 ranking, ST_AsMVT/ST_AsGeoJSON(record)/ST_AsGeobuf/ST_AsFlatGeobuf, and partman.create_parent + run_maintenance_proc
  • constructive-db application/app deploys, and its suites pass: metaschema data-bm25, data-search, data-embedding, embedding-chunks, data-history, data-postgis-aggregate, plus app blueprint.provision, provision-database.dynamic-types, partman-maintenance-task (196 passed)

Link to Devin session: https://app.devin.ai/sessions/06ead45d854d42a8bd5e29cf554a0a2b
Open in Devin Desktop: https://app.devin.ai/desktop/session/06ead45d854d42a8bd5e29cf554a0a2b?variant=devin
Requested by: @pyramation

@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@luxor-code-review

luxor-code-review Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 2 high · 🟡 1 medium

💬 Inline comments (3)


The PR introduces scripts/verify-postgres-security.sh as a release gate: it starts a throwaway container from the just-built image, verifies server_version_num meets a floor for the 2026-11-12 fixes, confirms SHOW composite_type_mismatch errors as expected post-CVE, and loads each bundled C extension to catch ABI mismatches. It is wired into the existing test lifecycle in the Makefile and invoked in both the PR and push paths of .github/workflows/docker.yml, with README.md documenting the gate and PG_MIN_VERSION_NUM override. Two defects undermine the gate's core purpose — a wrong version floor and psql swallowing SQL errors — plus an unbounded CI wait loop.

Files Change
scripts/verify-postgres-security.sh New verification script: version floor check, CVE GUC probe, CREATE EXTENSION loop over bundled extensions.
.github/workflows/docker.yml Adds security-verify steps to both PR and push jobs, running the new script against the built image.
Makefile Hooks the verify script into test and a new verify-security target within the start/verify/stop/rm lifecycle.
README.md Documents the security gate and the PG_MIN_VERSION_NUM environment override.

Reviewed commit: 653a608

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a post-build security verification gate that boots each built PostGIS image, checks the server version against a minimum carrying the 2026-11-12 security fixes, probes the CVE-related composite_type_mismatch GUC, and exercises bundled C extensions, wired into make test and both CI jobs.

Key findings

set -euo pipefail

container="${1:?usage: verify-postgres-security.sh <container>}"
psql() { docker exec -i "$container" psql -U postgres -X -q -At "$@"; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 bug · high

Set ON_ERROR_STOP for every psql call

The psql wrapper runs without ON_ERROR_STOP, so psql -c exits 0 even when the SQL statement fails (scripts/verify-postgres-security.sh:14). The || fail guards on the version probe, the SHOW composite_type_mismatch check, and the CREATE EXTENSION loop are therefore inert for SQL-level failures: an extension dying with an undefined symbol ABI mismatch prints to stderr while the script reports "PostgreSQL security verification passed". A build with an incompatible or unpatched server ABI passes the security gate and reaches a tag.

📋 Prompt for AI Agents

In scripts/verify-postgres-security.sh line 14, change the wrapper to psql() { docker exec -i "$container" psql -U postgres -X -q -At -v ON_ERROR_STOP=1 "$@"; } so server-side SQL errors (failed CREATE EXTENSION, unrecognized SHOW parameter) make psql exit non-zero and trigger the existing || fail guards. Then run the script against a built image: if CREATE EXTENSION pg_stat_statements fails with "must be loaded via shared_preload_libraries", confirm the image preloads it before keeping it in the loop.

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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 bug · high

Wrong PG_MIN_VERSION_NUM floor lets 18.1–18.6 pass

The default floor PG_MIN_VERSION_NUM=180007 decodes to 18.0.7, not 18.7: server_version_num is major*10000 + minor*100 + patch, so 18.7 is 180700 (scripts/verify-postgres-security.sh:17). The gate therefore accepts any 18.x server above 18.0.6 — including vulnerable 18.1–18.6 builds that predate the CVE-2026-6460 fix — defeating the stated purpose of the check. The gate runs from make test, make verify-security, and both CI verify steps, so an image built from a stale postgres:18-alpine pin passes verification and is tagged.

📋 Prompt for AI Agents

In scripts/verify-postgres-security.sh line 17, change the default from 180007 to 180700. PostgreSQL encodes minor releases in the hundreds digit of server_version_num (18.7 = 1810000 + 7100 = 180700), so 180007 actually means 18.0.7 and the current gate passes vulnerable 18.1–18.6 servers. Keep the env-overridable form.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 bug · medium

Add timeout to the pg_isready wait loops

The until docker exec postgis-verify pg_isready -U postgres -q; do sleep 1; done loops in both the PR and push gate steps have no timeout (.github/workflows/docker.yml:92). A container whose Postgres never becomes ready — bad entrypoint, crashed initdb — hangs the job until the 360-minute default job timeout. This wastes runner minutes and delays the real signal that the gate failed; the same unbounded loop appears at line 117.

📋 Prompt for AI Agents

In .github/workflows/docker.yml, in the 'Verify PostGIS security (PR, amd64)' step (around line 92) and the 'Verify PostGIS security (pushed digest)' step (around line 117), replace the unbounded until docker exec postgis-verify pg_isready -U postgres -q; do sleep 1; done loop with a bounded wait, e.g. a counter that exits 1 after 300 seconds and prints docker logs postgis-verify. This prevents a 6-hour CI hang when the container fails to start.

@pyramation
pyramation merged commit 2e6a6a4 into main Nov 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant