From 8f73a16f5cefcc2054bba5bb944f46f2e433e5bc Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 27 Oct 2026 11:22:33 +0100 Subject: [PATCH] fix: [plausible] close the unauthenticated code execution of ``/storybook`` with ``3.2.1`` Plausible Community Edition up to ``3.2.0`` serves ``/storybook``, which compiles and runs code sent by any visitor (CVE-2026-8467, GHSA-mhcv-h7gf-57cf). It was used to install cryptocurrency miners in the container of a ``3.0.1`` deployment. ``3.2.1`` removes the endpoint. - Use ``docker.0k.io/plausible:3.2.1`` (from ``ghcr.io/plausible/community-edition:v3.2.1``). The database migrations run at start as before; ``3.0.1`` data migrates without manual step. - The default web-proxy rules refuse ``/storybook``, in case an older image is ever deployed again. - The Erlang release cookie of the image is created when the image is built, so it is the same on every installation. The ``init`` hook now generates one per installation (``release-cookie``) and sets ``RELEASE_DISTRIBUTION`` to ``none``: this single node opens no ``epmd`` nor distribution port. Assisted-by: Claude:claude-opus-5-5 --- plausible/README.org | 38 +++++++++++++++++++++++++++++++++++++- plausible/hooks/init | 19 ++++++++++++++++++- plausible/metadata.yml | 10 ++++++++-- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/plausible/README.org b/plausible/README.org index f8d1908..e4275cf 100644 --- a/plausible/README.org +++ b/plausible/README.org @@ -4,4 +4,40 @@ From: https://github.com/plausible/community-edition/ -* Usage \ No newline at end of file +* Usage + +#+begin_src yaml +plausible: + relations: + web-proxy: + frontend: + domain: stats.example.com +#+end_src + +A =clickhouse= (statistics) and a =postgres= (accounts, sites) service +are added automatically. + +* Security + +- Plausible before 3.2.1 serves =/storybook=, which runs any code sent + to it without authentication (CVE-2026-8467, GHSA-mhcv-h7gf-57cf). + This charm uses 3.2.1, and its default web-proxy rules refuse + =/storybook= in case an older image is deployed again. +- The Erlang release cookie of the image is generated when the image is + built, so it is the same for every installation. The charm generates + its own (=release-cookie= in the service datastore) and sets + =RELEASE_DISTRIBUTION= to =none=: this single node opens no =epmd= nor + Erlang distribution port. + +* Upgrading from 3.0.x + +- Migrations run at each start (=db migrate= in the entrypoint), for + both PostgreSQL and ClickHouse. They cannot be reverted: back up both + databases first. +- Deploy together with the =clickhouse= charm of the same revision: the + ClickHouse low-memory profile moved to =users.d= (upstream change of + 3.2.0). +- Sites keep working with their existing tracking snippet. +- Changing =secret-key= signs everybody out, invalidates every API key, + and makes the 2FA secrets unreadable unless =TOTP_VAULT_KEY= is set + to the key derived from the previous one. diff --git a/plausible/hooks/init b/plausible/hooks/init index 251127b..586d5be 100755 --- a/plausible/hooks/init +++ b/plausible/hooks/init @@ -1,6 +1,10 @@ #!/bin/bash SECRET_KEY_BASE="$SERVICE_DATASTORE"/secret-key +## Erlang release cookie. The image ships one in ``/app/releases/COOKIE`` +## that is generated when the image is built, so it is the same for every +## installation of that image: replace it by one of our own. +RELEASE_COOKIE_FILE="$SERVICE_DATASTORE"/release-cookie SHARE_DIR="$SERVICE_DATASTORE"/var/lib/plausible mkdir -p $SHARE_DIR @@ -16,12 +20,25 @@ else info "Using existing secret key" fi -secret_key_base=$(cat "$SECRET_KEY_BASE") +if ! [ -f "$RELEASE_COOKIE_FILE" ]; then + info "Generating Erlang release cookie" + mkdir -p "${RELEASE_COOKIE_FILE%/*}" + (umask 077; openssl rand -hex 32 > "$RELEASE_COOKIE_FILE") +fi +secret_key_base=$(cat "$SECRET_KEY_BASE") +release_cookie=$(cat "$RELEASE_COOKIE_FILE") + +## ``RELEASE_DISTRIBUTION: none``: Plausible Community Edition runs a +## single node and never needs Erlang distribution (the ``db createdb`` and +## ``db migrate`` commands use ``eval``), so the node opens no ``epmd`` nor +## distribution port that anything else could connect to. init-config-add " $SERVICE_NAME: environment: SECRET_KEY_BASE: \"$secret_key_base\" + RELEASE_COOKIE: \"$release_cookie\" + RELEASE_DISTRIBUTION: \"none\" " chown -v "$uid" "$SHARE_DIR" diff --git a/plausible/metadata.yml b/plausible/metadata.yml index cdc46f5..386dc4f 100644 --- a/plausible/metadata.yml +++ b/plausible/metadata.yml @@ -1,5 +1,6 @@ -docker-image: docker.0k.io/plausible:3.0.1 -#docker-image: ghcr.io/plausible/community-edition:v3.0.1 +## 3.2.1 or later is required: earlier versions expose ``/storybook``, +## an unauthenticated remote code execution (CVE-2026-8467). +docker-image: docker.0k.io/plausible:3.2.1 ## from: ghcr.io/plausible/community-edition:v3.2.1 data-resources: - /var/lib/plausible @@ -49,6 +50,11 @@ uses: RewriteCond %{HTTP:Connection} upgrade [NC] RewriteRule ^/(live/websocket)$ ws://${MASTER_BASE_SERVICE_NAME}:8000/\$1 [P,L] + ## Plausible < 3.2.1 runs any code sent to /storybook + ## (CVE-2026-8467). 3.2.1 removed it; keep it closed in case + ## an older image is ever deployed again. + RewriteRule ^/storybook(/|$) - [F,L] + backup: constraint: recommended