Skip to Content
mlab docs

Hardening

Production checklist for a tprm.mlab.sh instance: secrets, network exposure, TLS, single sign-on enforcement, administrator recovery, the S3 bucket and updates.

What applies to a tprm.mlab.sh deployment, in the order to go through it.

Checklist

ItemSection
☐Every default password in .env replaced; .env readable by root onlySecrets
☐Only the reverse proxy is reachable; 8080, 3306, 8123 and 9000 are notNetwork exposure
☐TLS in front, COOKIE_SECURE=true, DEV=false, PUBLIC_URL setTLS and cookies
☐admin@localhost has a strong password, a second local administrator existsAdministrators
☐SSO only, if your users all come from an identity providerSingle sign-on
☐Bucket private, keys limited to its objectsS3 bucket
☐Image pinned, updates followed, backups encryptedUpdates

Secrets

The downloadable .env ships with changeme passwords. Replace each of them before the first start: MySQL and ClickHouse create their users from these values on an empty volume, and changing them later means changing them inside the databases too (see Troubleshooting).

openssl rand -hex 32   # DB_PASSWORD, DB_ROOT_PASSWORD, CH_PASSWORD
chmod 600 .env
SecretNotes
LICENSE_KEYRotate it on mlab.sh if it leaks: every instance is paused until it gets the new key. See Managing the license.
DB_PASSWORD, DB_ROOT_PASSWORD, CH_PASSWORDDB_ROOT_PASSWORD is used by the MySQL container only, never by the app.
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEYDedicated keys for this instance, see S3 bucket.
ADMIN_INITIAL_PASSWORDRead on the first start only. Remove it from .env once you have signed in.
MLAB_API_KEYOptional. An organisation's own key, set in the UI, takes precedence.
INTERNAL_SECRETLeave unset: internal service authentication stays disabled while it is unset or left at mlab_internal_change_me.

SSO client secrets, the mlab.sh API key set in the UI and API keys are stored in MySQL. Treat database dumps as secrets: see Backup and restore.

Network exposure

PortExpose to
443 (proxy)Your users.
8080 (app)The reverse proxy only.
3306 (mysql), 8123 / 9000 (clickhouse)Nobody outside the compose network.
  • Use the downloadable compose file, which publishes only the app. The repository's development compose publishes 3306 and 8123 on all interfaces.
  • Publish 8080 on the loopback when the proxy runs on the host ("127.0.0.1:8080:8080"), or not at all when the proxy is a container on the same network. See Reverse proxy.
  • Docker writes its own firewall rules: a port published on 0.0.0.0 is reachable even when ufw or firewalld say otherwise. Bind to an address rather than relying on the host firewall.
  • The app takes the client IP from Forwarded / X-Forwarded-For without checking who sent them. When only the proxy reaches port 8080, and overwrites them, the logged IP and the per-IP login limit (10 failures in 15 minutes) are reliable.

Outbound

Only https://mlab.sh (port 443) is required, for the license check. Allow the others only for the features you use: your identity provider, your S3 endpoint, mlab.sh for the public footprint scan, api.gleif.org for identifier checks. The full list is in Architecture.

TLS and cookies

.env
PUBLIC_URL=https://tprm.example.com
COOKIE_SECURE=true
DEV=false
  • COOKIE_SECURE=true (also the default when unset) marks the mlab_session cookie Secure and sends Strict-Transport-Security for a year, subdomains included.
  • DEV=true turns verbose request logging on, prints requests to the console and removes Secure from the cookie. Never in production.
  • The cookie is always HttpOnly and SameSite=Lax. The app sends X-Frame-Options: DENY, X-Content-Type-Options: nosniff and Referrer-Policy: strict-origin-when-cross-origin.

Administrators and recovery

  • Set admin@localhost's password on the first start (ADMIN_INITIAL_PASSWORD, or the one-time setup link in the logs), 12 characters or more.
  • Keep two local administrators with a password. They are the way back in when the identity provider is down, and a second one avoids depending on the database procedure below.
  • Password sign-in is limited to 10 failures per IP and per email in 15 minutes.
  • The platform sends no email. A lost admin@localhost password is reset from the database, which needs shell access to the host: Forgot the admin password. Restrict who has docker access on the host accordingly: it is root-equivalent and gives access to every secret and record.

Single sign-on

  • Turn on SSO only in Organization > Single sign-on once SSO works: password sign-in, reset links and invitations are off for everyone but local administrators. See SSO only.

  • Restrict Allowed email domains to your own domains.

  • Accounts created by OpenID Connect at first sign-in are members; roles are not mapped from the identity provider's groups.

  • Someone removed at the identity provider cannot sign in again, but a session already open stays valid until they sign out.

  • Give auditors and supervisors the Viewer role (Organization > Team): they read and export, and the API refuses any change from them. See Roles.

AI agents (MCP)

  • Set PUBLIC_URL to the https address: the OAuth server of the MCP endpoint announces it as its issuer.
  • An agent acts with the role of the user who connected it: connect one that only needs to read from a Viewer account.
  • Review Account settings, AI agents (MCP) from time to time and revoke the connected applications and personal tokens no longer used. Each user manages their own: an administrator cannot revoke them for someone else yet, so make a leaver a Viewer at least until their account is dealt with.
  • See AI agents (MCP) for how connections are secured.

S3 bucket

  • Private. Downloads go through the app, so the bucket needs no public access and no CORS rule. Block public access on it.
  • Least privilege. The app puts, gets and deletes objects and uses multipart uploads; it never lists the bucket. An example AWS IAM policy (adapt the bucket and prefix):
IAM policy (example)
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:AbortMultipartUpload"],
      "Resource": "arn:aws:s3:::tprm-docs/*"
    }
  ]
}
  • Encryption at rest on the bucket (SSE-S3 or SSE-KMS on AWS, or your provider's equivalent). Every document already keeps its SHA-256 in the database.
  • Versioning, and a lifecycle rule aborting incomplete multipart uploads after 1 day (see Large files).
  • HTTPS endpoint when the bucket is not on the same host or network: S3_ENDPOINT=https://....

Updates

  • Pin the image to a version tag rather than latest, and keep ClickHouse on the supported version. See Update.
  • Follow the changelog and take a backup before each upgrade (Before an upgrade).
  • Keep mysql:8 and the Docker engine patched with the host.
  • The app runs as the unprivileged mlab user inside the container.

On this page