fix: [plausible, clickhouse] close the /storybook code execution (Plausible 3.2.1) and apply ClickHouse low-memory settings #2

Merged
stephansainleger merged 2 commits from vlab/plausible-storybook-rce AGit into master 2026-11-05 08:25:41 +00:00
Owner

Why

Plausible Community Edition up to 3.2.0 serves /storybook, which compiles and runs code sent by any visitor, without authentication (CVE-2026-8467, GHSA-mhcv-h7gf-57cf). A deployment of this charm (3.0.1) was compromised through it: cryptocurrency miners ran in the Plausible container from mid-September. 3.2.1 removes the endpoint.

Changes

plausible

  • Image docker.0k.io/plausible:3.2.1 (cached from ghcr.io/plausible/community-edition:v3.2.1, already pushed).
  • Default web-proxy rules refuse /storybook (Apache returns 403), in case an older image is deployed again.
  • The image's Erlang release cookie is generated at image build time, so it is identical on every installation. The init hook now generates one per installation (release-cookie in the service datastore) and sets RELEASE_DISTRIBUTION=none: this single-node install opens no epmd / distribution port (migrations use eval, which does not need it).
  • README: security and upgrade notes.

clickhouse

  • The low-memory profile settings (max_threads 1, …) lived in a <profile> block of config.d/low-resources.xml, where ClickHouse ignores them. As upstream did in CE v3.2.0 (plausible/community-edition#265), they move to users.d/default-profile-low-resources-overrides.xml; config.d/low-resources.xml keeps only mark_cache_size.

Migration 3.0.1 → 3.2.1

  • No environment variable added or renamed upstream; ClickHouse 24.12 and PostgreSQL 17.2 stay compatible.
  • db migrate (already in the entrypoint) applies everything at start: PostgreSQL migrations up to 20251211110619, including a backfill of tracker_script_configuration (one row per site). The only new ClickHouse migration is Enterprise-only.
  • Migrations cannot be reverted: back up PostgreSQL and ClickHouse first.
  • Existing tracking snippets keep working.
  • Changing secret-key signs everybody out, invalidates API keys, and makes 2FA secrets unreadable unless TOTP_VAULT_KEY is pinned to the previously derived key.

Tests

Replayed on a test VPS with a copy of the compromised instance's data (6 users, 5 sites, ~194k events), deleted afterwards:

  1. deploy with the current charms (3.0.1, not exposed), restore the production data;
  2. switch to this branch, compose up, with Apache + Let's Encrypt.

Checked:

  • migrations complete; users/sites/shared links unchanged; per-site event and visit counts identical (e.g. 4770 visits on site 1, before and after);
  • /storybook: 404 from the application, 403 from Apache; /live/websocket upgrade: 101;
  • login, sites list and dashboard: 200; top-stats returns the same numbers;
  • a new pageview through /api/event: 202, recorded in events_v2;
  • ClickHouse system.settings: max_threads 1, max_block_size 8192 … all changed=1;
  • the Plausible container listens only on 8000 (no epmd, no distribution port), RELEASE_DISTRIBUTION=none.

Not in this PR

  • The ClickHouse default user has no password (as in upstream's own setup). It is not reachable from outside the docker network; worth hardening separately.
  • The clickhouse charm has no backup relation: statistics are not backed up.
## Why Plausible Community Edition up to 3.2.0 serves `/storybook`, which compiles and runs code sent by any visitor, without authentication ([CVE-2026-8467](https://cna.erlef.org/cves/CVE-2026-8467.html), [GHSA-mhcv-h7gf-57cf](https://github.com/plausible/analytics/security/advisories/GHSA-mhcv-h7gf-57cf)). A deployment of this charm (3.0.1) was compromised through it: cryptocurrency miners ran in the Plausible container from mid-September. 3.2.1 removes the endpoint. ## Changes **plausible** - Image `docker.0k.io/plausible:3.2.1` (cached from `ghcr.io/plausible/community-edition:v3.2.1`, already pushed). - Default web-proxy rules refuse `/storybook` (Apache returns 403), in case an older image is deployed again. - The image's Erlang release cookie is generated at image build time, so it is identical on every installation. The `init` hook now generates one per installation (`release-cookie` in the service datastore) and sets `RELEASE_DISTRIBUTION=none`: this single-node install opens no `epmd` / distribution port (migrations use `eval`, which does not need it). - README: security and upgrade notes. **clickhouse** - The low-memory profile settings (`max_threads` 1, …) lived in a `<profile>` block of `config.d/low-resources.xml`, where ClickHouse ignores them. As upstream did in CE v3.2.0 (plausible/community-edition#265), they move to `users.d/default-profile-low-resources-overrides.xml`; `config.d/low-resources.xml` keeps only `mark_cache_size`. ## Migration 3.0.1 → 3.2.1 - No environment variable added or renamed upstream; ClickHouse 24.12 and PostgreSQL 17.2 stay compatible. - `db migrate` (already in the entrypoint) applies everything at start: PostgreSQL migrations up to `20251211110619`, including a backfill of `tracker_script_configuration` (one row per site). The only new ClickHouse migration is Enterprise-only. - Migrations cannot be reverted: back up PostgreSQL and ClickHouse first. - Existing tracking snippets keep working. - Changing `secret-key` signs everybody out, invalidates API keys, and makes 2FA secrets unreadable unless `TOTP_VAULT_KEY` is pinned to the previously derived key. ## Tests Replayed on a test VPS with a copy of the compromised instance's data (6 users, 5 sites, ~194k events), deleted afterwards: 1. deploy with the current charms (3.0.1, not exposed), restore the production data; 2. switch to this branch, `compose up`, with Apache + Let's Encrypt. Checked: - migrations complete; users/sites/shared links unchanged; per-site event and visit counts identical (e.g. 4770 visits on site 1, before and after); - `/storybook`: 404 from the application, 403 from Apache; `/live/websocket` upgrade: 101; - login, sites list and dashboard: 200; `top-stats` returns the same numbers; - a new pageview through `/api/event`: 202, recorded in `events_v2`; - ClickHouse `system.settings`: `max_threads` 1, `max_block_size` 8192 … all `changed=1`; - the Plausible container listens only on 8000 (no epmd, no distribution port), `RELEASE_DISTRIBUTION=none`. ## Not in this PR - The ClickHouse `default` user has no password (as in upstream's own setup). It is not reachable from outside the docker network; worth hardening separately. - The `clickhouse` charm has no `backup` relation: statistics are not backed up.
vlab added 2 commits 2026-10-27 10:31:30 +00:00
The ``max_threads``, ``max_block_size``, ``max_download_threads`` and
parallel parsing and formatting settings were declared in a
``<profile>`` block of ``config.d/low-resources.xml``.  ClickHouse only
reads profile settings from users configuration files, so they were
silently ignored and the server used its defaults (one thread per core,
larger blocks).

Following the Plausible Community Edition change of ``v3.2.0`` (its
pull request 265), ``config.d/low-resources.xml`` now keeps only the
server setting ``mark_cache_size``, and the profile settings move to
``users.d/default-profile-low-resources-overrides.xml``, inside
``<profiles>``.  ``system.settings`` now reports ``max_threads`` 1.

Assisted-by: Claude:claude-opus-5-5
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
stephansainleger merged commit 8f73a16f5c into master 2026-11-05 08:25:41 +00:00
Sign in to join this conversation.
No description provided.