Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
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
./scripts/verify-pgvector-security.sh postgis-verify

- name: Build & push by digest
if: github.event_name != 'pull_request'
Expand All @@ -117,6 +118,7 @@ jobs:
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
./scripts/verify-pgvector-security.sh postgis-verify

- name: Export digest
if: github.event_name != 'pull_request'
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Multi-stage build - all toolchains discarded, only artifacts kept

ARG PG_VERSION=18
ARG PGVECTOR_VERSION=0.8.2
ARG PGVECTOR_VERSION=0.8.7
ARG POSTGIS_VERSION=3.6.4
ARG PG_TEXTSEARCH_VERSION=1.5.1
ARG PG_PARTMAN_VERSION=5.4.3
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ test: build
SELECT 'all extensions OK';"
@./scripts/verify-postgis-security.sh $(CONTAINER_NAME)-test
@./scripts/verify-postgres-security.sh $(CONTAINER_NAME)-test
@./scripts/verify-pgvector-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, nor a server older than 18.7 (CVE-2026-6460).
# CVE-2026-73514 / CVE-2026-73515, a server older than 18.7 (CVE-2026-6460),
# nor a pgvector older than 0.8.7 (CVE-2026-103484).
verify-security:
@./scripts/verify-postgis-security.sh $(CONTAINER_NAME)
@./scripts/verify-postgres-security.sh $(CONTAINER_NAME)
@./scripts/verify-pgvector-security.sh $(CONTAINER_NAME)

clean: stop
docker rmi $(IMAGE_NAME):$(IMAGE_TAG) || true
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Lean PostgreSQL 18 image with essential extensions for modern applications.

| Extension | Version | Description |
|-----------|---------|-------------|
| [pgvector](https://github.com/pgvector/pgvector) | 0.8.2 | Vector similarity search for embeddings |
| [pgvector](https://github.com/pgvector/pgvector) | 0.8.7 | Vector similarity search for embeddings |
| [PostGIS](https://postgis.net/) | 3.6.4 (+ security patches) | Spatial and geographic data |
| [pg_textsearch](https://github.com/timescale/pg_textsearch) | 1.5.1 | BM25 full-text search |
| [pg_partman](https://github.com/pgpartman/pg_partman) | 5.4.3 | Partition management |
Expand Down Expand Up @@ -50,7 +50,7 @@ CREATE EXTENSION pg_stat_statements;

```bash
make build # Build image
make test # Build, verify extensions, and run the PostGIS security gate
make test # Build, verify extensions, and run the security gates
make verify-security # Run the security gate against an already-running container
make run # Run container
make shell # psql into container
Expand Down Expand Up @@ -97,6 +97,19 @@ running server is below `server_version_num` 180007, when the
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.

## pgvector security floor

pgvector is built from the `v0.8.7` tag, the release that fixes CVE-2026-103484
([pgvector#1036](https://github.com/pgvector/pgvector/issues/1036)): an
out-of-bounds write during an IVFFlat index build, affecting 0.8.6 and below.

`scripts/verify-pgvector-security.sh <container>` is the gate: it fails when the
extension's default or installed version is below 0.8.7, and when `vector.so`
does not export `sparsevec_vector_dims`, the symbol the fix commit added, so a
library older than its SQL metadata is caught too. It builds no index. CI runs
it next to the other two gates. Raise `PGVECTOR_MIN_VERSION` when a later
release is the floor.

## Building manually

```bash
Expand Down
53 changes: 53 additions & 0 deletions scripts/verify-pgvector-security.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Fails if the image ships a pgvector build that is vulnerable to
# CVE-2026-103484 (out-of-bounds write during an IVFFlat index build,
# https://github.com/pgvector/pgvector/issues/1036 — affected <= 0.8.6,
# fixed in 0.8.7).
#
# Asserted against the *installed* extension and the *loaded* library, never
# against a Dockerfile ARG or a tag. The extension version is only SQL
# metadata, so the library is checked too: 0.8.7 is the first release whose
# vector.so exports `sparsevec_vector_dims`, added by the same commit as the
# fix (ee00d39), and binding a C function to that symbol fails on any older
# build. Nothing here builds an index or writes out of bounds.
#
# Usage: verify-pgvector-security.sh <container-name>
set -euo pipefail

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

PGVECTOR_MIN_VERSION="${PGVECTOR_MIN_VERSION:-0.8.7}"

fail() { echo "FAIL: $*" >&2; exit 1; }
ok() { echo "ok: $*"; }

below_floor() {
[ "$(printf '%s\n%s\n' "$PGVECTOR_MIN_VERSION" "$1" | sort -V | head -1)" != "$PGVECTOR_MIN_VERSION" ]
}

# 1. the version the image installs by default
available="$(psql -c "SELECT default_version FROM pg_available_extensions WHERE name = 'vector'")"
[ -n "$available" ] || fail "pgvector is not available in this image"
if below_floor "$available"; then
fail "pgvector default_version $available is below the patched floor $PGVECTOR_MIN_VERSION"
fi

# 2. the version a database actually gets
psql -c 'CREATE EXTENSION IF NOT EXISTS vector' >/dev/null
installed="$(psql -c "SELECT extversion FROM pg_extension WHERE extname = 'vector'")"
if below_floor "$installed"; then
fail "pgvector extension $installed is below the patched floor $PGVECTOR_MIN_VERSION"
fi
ok "pgvector $installed >= $PGVECTOR_MIN_VERSION"

# 3. the library itself carries the fix commit
psql >/dev/null 2>&1 <<'SQL' || fail "vector.so does not export sparsevec_vector_dims — library predates the CVE-2026-103484 fix"
BEGIN;
CREATE FUNCTION pg_temp.pgvector_fix_probe(sparsevec) RETURNS integer
AS '$libdir/vector', 'sparsevec_vector_dims' LANGUAGE C IMMUTABLE STRICT;
ROLLBACK;
SQL
Comment on lines +45 to +50

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 security · medium

Symbol probe is never called, so step 3 cannot fail

The CVE-2026-103484 probe in scripts/verify-pgvector-security.sh:45-50 only runs CREATE FUNCTION pg_temp.pgvector_fix_probe(sparsevec) ... AS '$libdir/vector', 'sparsevec_vector_dims' and immediately rolls back. PostgreSQL resolves the C symbol lazily at first call, so a pre-fix vector.so still passes this step and the "fix compiled in" assertion is vacuous; only the SQL version checks in steps 1-2 are actually enforced.

📋 Prompt for AI Agents

In scripts/verify-pgvector-security.sh around lines 45-50, the heredoc creates the probe function but never calls it, so PostgreSQL never resolves the 'sparsevec_vector_dims' symbol and the CVE fix assertion always passes. Insert SELECT pg_temp.pgvector_fix_probe(sparsevec '1:1'::sparsevec); (any valid sparsevec literal) after the CREATE FUNCTION and keep the ROLLBACK after the SELECT.

ok "vector.so exports sparsevec_vector_dims (CVE-2026-103484 fix compiled in)"

echo "pgvector security verification passed"
Loading