Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

build(docker): commit the PostgreSQL signing key instead of fetching it

Yudhi Armyndharisad90b4c47a0e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2efcfac65..261a29ad1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Plugin config fields bind their caption to the control for every field type, not just booleans. Clicking the caption of a text, number, secret, enum or textarea field focused nothing, and screen readers announced those inputs with no name.
- Dashboard toggles expose an accessible name and, for the message-type and recipient groups, their selected state. Their captions sit outside the control, so a screen reader announced anonymous checkboxes and unlabelled buttons.
+- The PostgreSQL signing key is committed instead of fetched during the image build, so the one build input nothing pinned is now reviewable and diffable, and a release build makes one fewer uncached network call.
- The image ships the PostgreSQL client, so `backup.sh` and `restore.sh` work in-container with `DATABASE_TYPE=postgres`. Neither `pg_dump` nor `psql` was present, so the backup exited 1 and the restore printed an import that could not be run.
- A session launch that fails on a locked database is retried. The classifier looked for `SQLITE_BUSY` in the error message while the driver carries it on `code`, so the session stayed down until a restart.
- Meta-hosted ids (`@hosted`, `@hosted.lid`) normalize to the dialect they name. They parsed as unknown before, so a chat surfaced with kind `unknown` and the same id was then refused with a `400` on any write.
diff --git a/Dockerfile b/Dockerfile
index e5e2be59f..cd8f18856 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -81,9 +81,6 @@ ARG TARGETARCH
# snapshots (.backup) instead of plain-copying a live database (which can archive a torn file). The
# DATABASE_TYPE=postgres half of the same script needs pg_dump, installed further down.
#
-# ca-certificates is required to fetch the PGDG signing key over HTTPS below: the base image has no
-# CA bundle, and curl alone does not pull one in under --no-install-recommends (curl: (77)).
-#
# ffmpeg backs the opt-in media-conversion endpoints, and also repairs an existing gap: whatsapp-web.js
# requires fluent-ffmpeg at module load and calls it for video-to-webp animated stickers, so
# sendSticker with a video mimetype has been failing in this image for want of the binary. Measured
@@ -114,7 +111,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
patch \
curl \
procps \
- ca-certificates \
sqlite3 \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
@@ -130,10 +126,27 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# client may be newer than its server, never older), and DATABASE_HOST often points at a managed
# Postgres the compose file does not control, where 17 is the current default. Pinning to 16 would
# have left every such deployment unable to back up. Verified against live 16 and 17 servers.
-RUN install -d /usr/share/postgresql-common/pgdg \
- && curl -fsSL -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
- https://www.postgresql.org/media/keys/ACCC4CF8.asc \
- && echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \
+#
+# The signing key is committed rather than fetched at build time. Fetched, it was the one build input
+# nothing pinned: `signed-by` attests only that the .debs match whatever that request returned, so a
+# compromised host, or a build behind a TLS-intercepting proxy whose root is in the trust store,
+# would swap the trust anchor with nothing to notice. Committed, it is reviewed once and diffable
+# forever, and it removes one of the two network calls the release build makes uncached
+# (release.yml's `no-cache-filters: production` rebuilds this stage every tag, on both platforms).
+# Verify with `gpg --show-keys --with-fingerprint scripts/pgdg-ACCC4CF8.asc`:
+# B97B0AFC AA1A47F0 44F244A0 7FCC7D46 ACCC4CF8, uid "PostgreSQL Debian Repository".
+#
+# 10 packages arrive with it on top of the list above (12 on a bare base; sqlite3 already brings
+# libreadline8), including a full perl interpreter: /usr/bin/pg_dump is a symlink to
+# postgresql-common's pg_wrapper, which is a perl script. Trivy on the built image, with the release
+# job's own settings (CRITICAL,HIGH + ignore-unfixed + .trivyignore): 0 findings, the bar the ffmpeg
+# layer above was held to. Counting unfixed ones too, the perl packages carry 8 CRITICAL/HIGH with
+# no upstream fix, but every one of them is a CVE the base image ALREADY had through perl-base
+# (Debian essential, present before this layer), so the layer adds 0 distinct vulnerabilities.
+# libpq5 and the postgresql-client packages themselves are clean. Recheck with:
+# trivy image --vuln-type os,library --severity CRITICAL,HIGH --ignore-unfixed --ignorefile .trivyignore <image>
+COPY scripts/pgdg-ACCC4CF8.asc /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc
+RUN echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \
http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update && apt-get install -y --no-install-recommends postgresql-client-17 \
&& rm -rf /var/lib/apt/lists/*
diff --git a/scripts/check-dockerignore.mjs b/scripts/check-dockerignore.mjs
index 463af7a29..d208f7772 100644
--- a/scripts/check-dockerignore.mjs
+++ b/scripts/check-dockerignore.mjs
@@ -147,6 +147,7 @@ const mustKeep = [
'scripts/patch-wwebjs-status.js',
'scripts/patch-wwebjs-ready-sync.js',
'scripts/wwebjs-201832.patch',
+ 'scripts/pgdg-ACCC4CF8.asc',
'scripts/backup.sh',
'scripts/restore.sh',
'scripts/lib-env.sh',
diff --git a/scripts/pgdg-ACCC4CF8.asc b/scripts/pgdg-ACCC4CF8.asc
new file mode 100644
index 000000000..8480576ec
--- /dev/null
+++ b/scripts/pgdg-ACCC4CF8.asc
@@ -0,0 +1,77 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQINBE6XR8IBEACVdDKT2HEH1IyHzXkb4nIWAY7echjRxo7MTcj4vbXAyBKOfjja
+UrBEJWHN6fjKJXOYWXHLIYg0hOGeW9qcSiaa1/rYIbOzjfGfhE4x0Y+NJHS1db0V
+G6GUj3qXaeyqIJGS2z7m0Thy4Lgr/LpZlZ78Nf1fliSzBlMo1sV7PpP/7zUO+aA4
+bKa8Rio3weMXQOZgclzgeSdqtwKnyKTQdXY5MkH1QXyFIk1nTfWwyqpJjHlgtwMi
+c2cxjqG5nnV9rIYlTTjYG6RBglq0SmzF/raBnF4Lwjxq4qRqvRllBXdFu5+2pMfC
+IZ10HPRdqDCTN60DUix+BTzBUT30NzaLhZbOMT5RvQtvTVgWpeIn20i2NrPWNCUh
+hj490dKDLpK/v+A5/i8zPvN4c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