Repository navigation
ci: block publishing a PostgreSQL server below 18.7 (CVE-2026-6460) - #18
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. 🟠 2 high · 🟡 1 medium 💬 Inline comments (3)
The PR introduces
Reviewed commit: 653a608 |
There was a problem hiding this comment.
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
ON_ERROR_STOPfor everypsqlcall — verify-postgres-security.sh:14 - 🟠 Wrong
PG_MIN_VERSION_NUMfloor lets 18.1–18.6 pass — verify-postgres-security.sh:17 - 🟡 Add timeout to the
pg_isreadywait loops — docker.yml:92
| set -euo pipefail | ||
|
|
||
| container="${1:?usage: verify-postgres-security.sh <container>}" | ||
| psql() { docker exec -i "$container" psql -U postgres -X -q -At "$@"; } |
There was a problem hiding this comment.
🟠 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}" |
There was a problem hiding this comment.
🟠 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 | |||
There was a problem hiding this comment.
🟡 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.
Summary
The published
postgres-plus:18is still PostgreSQL 18.6 (built 2026-10-13).postgres:18-alpinemoved 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 floatingpostgres:18-alpinetag and compiles every extension from source against it. This PR adds a gate, and merging it to main rebuilds and republisheslatest/18on 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 < 180007composite_type_mismatchis missing or noterror. The CVE-2026-6460 fix added this setting, so if it's missing, the fix isn't in the server.vector,postgis,pg_textsearch,pg_partman,pg_stat_statementswon't load. 18.7 changed the server ABI, so an extension built against 18.6 fails to load withundefined 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:
constructiveio/postgres-plus:18(server_version_num 180006 is below the patched floor 180007)ST_AsMVT/ST_AsGeoJSON(record)/ST_AsGeobuf/ST_AsFlatGeobuf, andpartman.create_parent+run_maintenance_procapplication/appdeploys, and its suites pass: metaschemadata-bm25,data-search,data-embedding,embedding-chunks,data-history,data-postgis-aggregate, plus appblueprint.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