Skip to Content
mlab docs

Hardening

Production hardening for ir.mlab.sh: secrets, network exposure, the default and invited accounts, two-factor authentication, container privileges, egress, updates and logs.

Work through this list before the instance holds real incident data. Each item says what the platform does by default and what to change.

Secrets

SecretUsed byNotes
INTERNAL_SECRETapp and executorAuthenticates executor callbacks (Authorization: Internal ...). No default, and the served compose does not check it: set it before the first start. The app refuses internal auth if it is blank. Anyone holding it and able to reach /api/v1 can act as the executor.
DB_PASSWORD, DB_ROOT_PASSWORDapp, mysqlFixed into the MySQL volume at first init.
CH_PASSWORDapp, executor, clickhouseFixed into the ClickHouse volume at first init.
LICENSE_KEYappSent to mlab.sh only. Rotate it from mlab.sh/orga/ir/license if it leaks.

Generate each one independently:

openssl rand -hex 32

Then lock the file down:

chmod 600 .env

Keep .env out of version control and include it in encrypted backups (Backup and restore). Changing a database password after first init means changing it inside MySQL/ClickHouse too, not only in .env.

Network exposure

The stock compose file publishes only app, on every host interface. mysql, clickhouse and executor are reachable only on the compose network. Keep it that way:

  • Bind app to loopback when the proxy runs on the same host: "127.0.0.1:${APP_PORT:-8080}:8080". Then the only way in is the TLS proxy (Reverse proxy and TLS).
  • Never publish executor. Its POST /execute endpoint has no authentication; network isolation is its only protection.
  • Never publish 3306 or 9000, and don't attach unrelated containers to the project network.
  • Host firewall: allow inbound 443 (and 80 for ACME) to the proxy only.

Optional proxy rules, nginx syntax, as examples:

# Internal service auth never legitimately arrives through the proxy:
# the executor calls the app directly on the compose network.
if ($http_authorization ~* "^Internal ") { return 403; }

# The app does not rate-limit password attempts on /api/v1/auth/login.
# (limit_req_zone goes in the http {} block)
limit_req_zone $binary_remote_addr zone=irlogin:10m rate=10r/m;
location = /api/v1/auth/login {
    limit_req zone=irlogin burst=5 nodelay;
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host            $host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Forwarded       "";
}

Second-factor endpoints are rate limited by the app per client IP, which is why the proxy must overwrite X-Forwarded-For and drop Forwarded.

Accounts

The default admin

At every boot the app looks for a user with the email admin@localhost:

  • If it exists, it is re-granted full admin permissions. Demoting it does not last.
  • If it does not exist, the app creates it, with the password adminadmin, in a new default organisation.

So:

  1. Sign in as admin@localhost on first start and change the password immediately.
  2. Enable a second factor on it.
  3. Don't delete it. A deleted default admin comes back at the next restart with the well-known password.
  4. Create named accounts for people and use those day to day.

Users created from the console

Users added under Organization > Team start with the password changeme. Tell each new user to sign in and change it at once, or create accounts only once REQUIRE_2FA=true is in force so a password alone is not enough.

Two-factor authentication

# .env
REQUIRE_2FA=true                  # every user enrols before reaching the console
WEBAUTHN_RP_ID=ir.example.com     # enable passkeys (set both or neither)
WEBAUTHN_ORIGIN=https://ir.example.com
TOTP_ISSUER=ir.example.com        # label in authenticator apps

Removing a factor always asks for the password again. An administrator can reset a user's second factor at /orga/team/reset-2fa, within their own organisation only.

Sessions and API keys

Sessions last 7 days, with at most 3 concurrent sessions per user. The cookie is HttpOnly, SameSite=Lax, and Secure unless COOKIE_SECURE=false; leave it on.

API keys (Settings > API keys) come in two kinds: an account key acts with its owner's permissions; an app token can only create alerts. Give SIEM/EDR integrations app tokens. Refused app-token calls are logged as App token refused on <method> <path> (key note: ...), which names the integration.

Container privileges

Both mlab images run as the unprivileged user mlab, not root, and listen on unprivileged ports. You can tighten further. Example override, test it on a staging copy first:

docker-compose.override.yml
services:
  app:
    cap_drop: [ALL]
    security_opt: ["no-new-privileges:true"]
  executor:
    cap_drop: [ALL]
    security_opt: ["no-new-privileges:true"]

Leave DEV unset or false: DEV=true dumps every API request (path, client IP, user and organisation) to stdout.

Outbound traffic

The full list is in Architecture. For an egress allow-list:

  • app needs mlab.sh:443 (licence). Add vuln.mlab.sh:443, enrichment providers and webhook destinations only for features you use.
  • executor needs only the targets of your playbooks.

Playbook HTTP nodes refuse localhost, *.local, *.internal and literal private, loopback, link-local, CGNAT and reserved IP addresses, and re-check every redirect. The check reads the URL as written; it does not resolve DNS, so a public name that resolves to an internal address is not caught. If playbook authors are not fully trusted, restrict the executor's egress at the network level.

Updates

  • Pin image tags instead of latest and upgrade deliberately (Update).
  • Keep ClickHouse on the version the release is tested against (clickhouse/clickhouse-server:26.8 for 1.1.0).
  • Patch mysql:8 and the host OS on your normal cycle.
  • Back up before every upgrade: migrations do not roll back.

Logs and audit trail

  • The request log in ./log/<date>.log records, for every request, the client IP, user agent, path and the signed-in user's name and email. Treat it as personal data: restrict access and set a retention. The app never rotates or deletes it, see Monitoring and logs.
  • The activity log in ClickHouse is append-only with a checksum chain (checksum, prev_checksum) and a 2-year TTL. Back up clickhouse_data if you need it longer than the host lives.
  • Ship container stdout to your log platform so licence, migration and authentication warnings survive the container.

Checklist

  • INTERNAL_SECRET and all database passwords generated, .env mode 600
  • app bound to 127.0.0.1, served only through a TLS proxy with HSTS
  • Proxy overwrites X-Forwarded-For, drops Forwarded
  • Login rate limit at the proxy
  • admin@localhost password changed, second factor enrolled, not deleted
  • REQUIRE_2FA=true; WEBAUTHN_* set if passkeys are wanted
  • Integrations use app tokens
  • Image tags pinned, ClickHouse on the tested version
  • Backups encrypted and a restore tested
  • Request-log retention in place

On this page