Skip to content

Harden an exposed installation

PerfShop ships ready for training: its default accounts and secrets are training credentials, documented (directory of the welcome page, labs). This suits a stack on the trainer's machine or a closed classroom network — not an installation reachable from the Internet or from a network you do not control. This page lists what is already specific to each installation, describes the relay that guards the Docker socket, then lists what to change before exposing one.

Labs quote the training credentials

On a hardened installation, the accounts quoted by the labs and by the welcome page directory no longer have their default passwords: give the new ones to the students through another channel.

Already specific to each installation

These secrets are generated on first start: they are neither in the repository nor in the documentation, and are never written to the logs.

Secret Generated by Where Rotation
Password of the automation technical accounts (ci-0 to ci-3, ci-empty) perfshop-app training-secret volume (/training/password, mode 600) docker exec perfshop-app rm /training/password, then restart perfshop-app
Key pair and RS512 token of the Squash orchestrator perfshop-orchestrator-keys orchestrator-trust (public key) and orchestrator-secret (private key, token; mode 600) volumes see below
SSH key from the orchestrator to the runner perfshop-test-runner runner-ssh volume (/ssh-keys, mode 600) docker exec perfshop-test-runner rm /ssh-keys/id_ed25519, restart the runner, then the orchestrator
Forgejo tokens (Scripts UI; Squash TM SCM server) perfshop-forgejo-seed forgejo-token-data volume revoke the token in Forgejo, then replay the seed (docker compose up --no-deps --force-recreate perfshop-forgejo-seed): it renews it

Rotating the orchestrator keys (the new token must be pasted again in Squash TM, Administration › Automated execution servers):

docker compose run --rm --no-deps perfshop-orchestrator-keys sh -c 'rm -f /secret/* /trust/*'
docker compose run --rm --no-deps perfshop-orchestrator-keys
docker compose run --rm --no-deps perfshop-orchestrator-keys cat /secret/squash_autom_token
docker compose restart perfshop-orchestrator

Docker socket: the relay

The Docker daemon socket (/var/run/docker.sock) gives control over the whole host machine: whoever talks to it can create a privileged container, mount the host disk, read the secrets of the other containers. Up to the previous version, seven services mounted it: Scripts UI, JMeter UI, Test-AI, the Forgejo seed and Vector read-write, Monitoring and Promtail as :ro — which limited nothing: a read-only mount prevents neither connecting to the socket nor calling the whole API. Whoever took control of one of these interfaces took the host.

The perfshop-docker-relay service (docker-relay/ folder) is now the only one that mounts the daemon socket. The seven others talk to it, and each gets only the calls its feature needs:

Scripts UI ───── docker-relay-scripts-ui ─────┐
JMeter UI ────── docker-relay-jmeter-ui ──────┤
Test-AI ──────── docker-relay-test-ai ────────┤
Forgejo seed ─── docker-relay-forgejo-seed ───┼──> perfshop-docker-relay ──> /var/run/docker.sock ──> Docker daemon
Monitoring ───── docker-relay-monitoring ─────┤    (rights table,            (mounted by the relay,
Vector ───────── docker-relay-vector ─────────┤     refusals, journal)        and by it alone)
Promtail ─────── docker-relay-promtail ───────┘

client           named volume of the client: mounted by it alone,
                 read-only, on /run/docker-relay

The relay listens on one UNIX socket per client. Each socket lives in a named volume, docker-relay-<client>, that this client alone mounts, read-only, on /run/docker-relay; the socket is /run/docker-relay/docker.sock. The volume is the identity: the socket a request arrives on tells who is asking. There is no password and no token to keep.

Protection How What it prevents
A single service mounts the daemon socket /var/run/docker.sock appears only in the perfshop-docker-relay block of the compose files an interface that has been taken over talking to the daemon
One socket per client one docker-relay-<client> volume per client, mounted by it alone, read-only a client passing itself off as another
Closed rights table docker-relay/src/policy.js: what is not listed is refused (403); nothing is configurable at run time a client stepping outside its feature
Rewritten requests the relay reads the whole request, judges it, then writes its own to the daemon; one request per connection; any ambiguous form is refused a request being read differently by the daemon and by the relay
Reduced answers lists limited to the client's containers; of a container, only what a client reads is kept (identity, state, image, Compose labels, address on the network): no environment, no command line, no health check, no mount; event stream limited to the life of the containers; API version older than 1.28 refused seeing the other applications of the host, reading the secrets of a container or the directories of the host
No network, no port network_mode: none, no published port reaching the relay other than through its sockets
Locked container read_only: true, cap_drop: ALL, security_opt: no-new-privileges:true altering the relay, gaining privileges in it
Limits pids_limit, mem_limit; request size, time to send it, number of connections and bytes in memory bounded per client; a client that keeps writing after its request is no longer read, then cut a client exhausting the relay or the machine, or slowing the other clients down

What each client gets. The table is docker-relay/src/policy.js; widening an access means changing that file.

Client Volume Socket set by What the relay grants
Scripts UI (perfshop-scripts-ui) docker-relay-scripts-ui DOCKER_SOCKET state of perfshop-test-runner; commands in that container only (run a Robot Framework or pytest script, synchronise the Forgejo repository)
JMeter UI (perfshop-jmeter-ui) docker-relay-jmeter-ui DOCKER_SOCKET state of perfshop-jmeter; commands in that container only (test run, report, stop, reading the JMeter log); reading its own container log
Test-AI (perfshop-test-ai) docker-relay-test-ai DOCKER_SOCKET_PATH commands in perfshop-playwright only (streamed Playwright run, snapshot, video recording)
Forgejo seed (perfshop-forgejo-seed) docker-relay-forgejo-seed DOCKER_HOST commands in perfshop-forgejo only, always as user git, pinned by the relay (the seed runs the Forgejo CLI there, to create the administrator)
Monitoring (perfshop-monitoring) docker-relay-monitoring DOCKER_SOCKET list and statistics of four containers: perfshop-frontend, perfshop-app, perfshop-db, perfshop-monitoring; restart of perfshop-app alone — the trainer's "Restart the backend" button of the monitoring admin — with a stop timeout of 10 s set by the relay (no parameter of the client is relayed)
Vector (perfshop-vector) docker-relay-vector docker_host in vector/vector.toml reading the logs of the containers of its include_containers list (API version, list, state, logs, events); no action
Promtail (perfshop-promtail) docker-relay-promtail host in promtail/promtail-config.yml reading the logs of the four containers of its filter (API version, list, state, logs, network of the stack); no action

DOCKER_SOCKET and DOCKER_SOCKET_PATH are /run/docker-relay/docker.sock; DOCKER_HOST, docker_host and host are unix:///run/docker-relay/docker.sock. The three variables are set by docker-compose.desktop.yml and docker-compose.build.yml: without them, the code of the five services that read them looks for /var/run/docker.sock, which they no longer mount. The lists of Vector and Promtail must stay equal to those of policy.js: a container added on one side and not on the other is not read. Likewise, a renamed target container (TEST_RUNNER_CONTAINER, JMETER_CONTAINER_NAME, PLAYWRIGHT_CONTAINER_NAME, FORGEJO_CONTAINER) must be renamed in policy.js too.

Everything else in the Docker API is refused (403) and logged: creating or removing a container, mounting a host folder, running a privileged command or a command in another container, stopping, starting or restarting any other container than the backend. A command started by a client runs as the user of the target container; the Privileged, User, WorkingDir and AttachStdin options are not relayed, and a request that carries one is refused (only the Forgejo seed may write User, and only git).

Reading the journal (one JSON line per event, on the standard output of the container):

docker logs perfshop-docker-relay
  • listening on start, for each client served; skipped for a client whose volume is not mounted in the relay (an installation may leave a service out);
  • refused for each refused call, at once, with the client, the status and the reason — beyond a limit per minute, further refusals are only counted (refused_not_printed);
  • summary once a minute: the relayed calls, counted per client, per call and per container;
  • failed for a call that does not complete, piped calls included (daemon unreachable or silent, unexpected answer, too many connections or too many bytes held by one client).
{"t":"2026-10-12T10:10:52.878Z","client":"scripts-ui","verdict":"refused","status":403,"reason":"route_not_relayed","detail":"POST /containers/create"}
{"t":"2026-10-12T10:10:52.878Z","verdict":"summary","relayed":{"scripts-ui exec.create perfshop-test-runner":1,"scripts-ui exec.start perfshop-test-runner":1,"scripts-ui exec.inspect perfshop-test-runner":1}}

The journal never holds the body of a request nor the value of a parameter: no command, no environment variable. Of a refused call it keeps at most the method and the path, or the name of the offending option. The refused client itself receives 403 and a docker-relay: … message. For a diagnosis, RELAY_LOG=all in the environment of the container logs every relayed call; the compose files do not set this variable.

Check (no write; from the repository root):

grep -n "/var/run/docker.sock" docker-compose.desktop.yml docker-compose.build.yml   # one line per file: the relay's
node tools/securite/socket-relaye.mjs --compose --conteneurs                          # guard: tracked files and running stack, "== 0 écart(s)"
cd docker-relay && node --test "test/*.test.js"                                       # the relay's suite, on a fake daemon

The guard tools/securite/socket-relaye.mjs checks that the relay's table, the compose files and the lists of Vector and Promtail agree. It also refuses whatever would hand the socket to another program: a build context, an image, a health check or a variable of the relay other than its own, and any host path that holds the socket of a container engine (/run, /proc, an account's directory…), even when written through a variable's default, with . or .., or through a YAML escape; its rules: tools/securite/README.md. The container has a health check (docker-relay/src/healthcheck.js): it is "healthy" only when the daemon answers and the relay answers on every client socket; its clients start only afterwards (depends_on, condition: service_healthy). To add a client: docker-relay/README.md.

The relay ships in docker-compose.desktop.yml and docker-compose.build.yml. A local or older compose file that still mounts the daemon socket in another service leaves that service outside the relay: the guard, run on that file (--compose <file>), shows it — searching for /var/run/docker.sock only sees the literal writing.

What the relay does not do

  • It does not protect the execution containers themselves: a student's code still runs in perfshop-test-runner, a JMeter plan in perfshop-jmeter, a Playwright test in perfshop-playwright. Whoever takes control of Scripts UI can still run commands in the runner; what the relay refuses them is the rest of the Docker API.
  • It does not replace the rule of this page: do not expose an installation with the default credentials.
  • It only covers the services of its table. An installation that adds a service needing the Docker API gives it an entry in policy.js, never the daemon socket.
  • It does not remove access to the daemon: it narrows it down to a single service, with no network and no port, whose code has no dependency.
  • It does not rewrite a stream: the output of a command and the log of a container go through as the daemon writes them, and an event still carries the labels of its container — Compose writes the directory of the project on the host there. Keep secrets out of command arguments all the same: docker ps and docker top show them on the host.
  • It is one process for seven clients: stopped, their seven features stop. Its own journal is shipped neither by Vector nor by Promtail.

To change before exposing an installation

1. A .env file outside the repository, with strong values

.env is ignored by git. Set in it, before the first start, a strong value for each variable below (otherwise the compose files provide a training value):

Variable Protects
ADMIN_PASSWORD trainer account of the PerfShop admin
DB_PASSWORD, DB_ROOT_PASSWORD the shop MySQL database
SQUASH_ADMIN_PASSWORD, SQUASH_DB_PASSWORD Squash TM and its database
FORGEJO_ADMIN_PASSWORD, FORGEJO_CI_PASSWORD Forgejo (administrator, CI account)
GF_SECURITY_ADMIN_PASSWORD, GRAFANA_STUDENT_PASSWORD Grafana
OPENSEARCH_ADMIN_PASSWORD OpenSearch
SESSION_SECRET sessions of Scripts UI, JMeter UI and Test-AI (see 2)
TEST_AI_MASTER_KEY encryption (AES-256-GCM) of the API keys stored in Test-AI — changing it makes the stored ones unreadable
openssl rand -base64 24   # a password
openssl rand -hex 32      # SESSION_SECRET, TEST_AI_MASTER_KEY (64 hexadecimal characters)

Accounts created on first start

The database, Forgejo and Squash TM accounts are created on first start with the .env value at that time. Changing .env afterwards does not change an existing account: change its password in the application too.

2. Session secret of the Node interfaces

Scripts UI, JMeter UI and Test-AI sign their session cookies with SESSION_SECRET. With the default value, Scripts UI says so on start: Session secret : ⚠ DEV DEFAULT (docker logs perfshop-scripts-ui). With a strong value in .env, the line becomes ✓ custom. Changing this secret closes the open sessions.

3. Squash TM: secret of the personal API tokens

Squash TM personal API tokens are signed with squash.rest-api.jwt.secret, set in squash-seed/squash.tm.cfg.properties. This file is tracked by git: its value is public. On an exposed installation, mount instead a local copy (outside the repository) where this line holds a secret of at least 512 bits:

openssl rand -base64 64

then recreate perfshop-testmgmt. Personal API tokens already issued are no longer valid: recreate them. The SQUASH_JWT_SECRET variable of the compose files is not read by any Squash TM configuration (measured on 2026-09-30): do not rely on it.

4. Publish only the necessary ports

By default, the compose files publish the ports of every interface and of the infrastructure — except Selenium's, bound to the machine only. On an exposed installation, publish only the entry points, behind an HTTPS reverse proxy, and bind the others to the host only ("127.0.0.1:3003:80") or remove them:

Never expose Default ports
Databases 19306 (MySQL), 5433 (Squash PostgreSQL)
Observability 9092 (Prometheus), 19100 (Loki), 19200, 4317, 4318 (Tempo), 4040 (Pyroscope, read-only through the landing page), 9201, 5601 (OpenSearch)
Test browser 4444, 7900 (Selenium, noVNC) — 4444 is bound to the machine only, with no variable: never publish it; the 7900 desktop, view-only, is opened to the network by the example file (students watch it): on an exposed installation, set SELENIUM_VNC_BIND=127.0.0.1 (Selenium)
Trainer interfaces 3003 (chaos), 3004 (admin), 3001 (monitoring), 3008 (Scripts UI), 3005 (JMeter UI), 3006 (Test-AI), 3002 (Grafana), 3009 (Forgejo), 9086 (Squash TM) — behind the proxy, with authentication, never in clear

5. Keys published in the git history

Until 2026-09-30, the orchestrator key pair (squash-orchestrator/trusted_key.pem and .pub) and the token signed with it were in the repository, and the runner accepted root with a password written in its Dockerfile. The git history is not rewritten: these values remain public. They are worthless for an up-to-date installation — keys regenerated on first start, password refused by the runner — but an installation created before that date and never updated must:

  • apply the up-to-date compose files (no more mount of squash-orchestrator/trusted_key.pub), then start perfshop-orchestrator-keys and paste the new token in Squash TM;
  • rebuild perfshop-test-runner (image without a root password).

Going further

Recommendation (lot to plan): generate all credentials at installation, like the technical accounts, and show them once to the trainer. Impact: every lab and the welcome page directory that quote an account.