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
| Item | Section | |
|---|---|---|
| ☐ | Every default password in .env replaced; .env readable by root only | Secrets |
| ☐ | Only the reverse proxy is reachable; 8080, 3306, 8123 and 9000 are not | Network exposure |
| ☐ | TLS in front, COOKIE_SECURE=true, DEV=false, PUBLIC_URL set | TLS and cookies |
| ☐ | admin@localhost has a strong password, a second local administrator exists | Administrators |
| ☐ | SSO only, if your users all come from an identity provider | Single sign-on |
| ☐ | Bucket private, keys limited to its objects | S3 bucket |
| ☐ | Image pinned, updates followed, backups encrypted | Updates |
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| Secret | Notes |
|---|---|
LICENSE_KEY | Rotate 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_PASSWORD | DB_ROOT_PASSWORD is used by the MySQL container only, never by the app. |
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY | Dedicated keys for this instance, see S3 bucket. |
ADMIN_INITIAL_PASSWORD | Read on the first start only. Remove it from .env once you have signed in. |
MLAB_API_KEY | Optional. An organisation's own key, set in the UI, takes precedence. |
INTERNAL_SECRET | Leave 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
| Port | Expose 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.0is reachable even whenufworfirewalldsay otherwise. Bind to an address rather than relying on the host firewall. - The app takes the client IP from
Forwarded/X-Forwarded-Forwithout 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
PUBLIC_URL=https://tprm.example.com
COOKIE_SECURE=true
DEV=falseCOOKIE_SECURE=true(also the default when unset) marks themlab_sessioncookieSecureand sendsStrict-Transport-Securityfor a year, subdomains included.DEV=trueturns verbose request logging on, prints requests to the console and removesSecurefrom the cookie. Never in production.- The cookie is always
HttpOnlyandSameSite=Lax. The app sendsX-Frame-Options: DENY,X-Content-Type-Options: nosniffandReferrer-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@localhostpassword is reset from the database, which needs shell access to the host: Forgot the admin password. Restrict who hasdockeraccess 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_URLto 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):
{
"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:8and the Docker engine patched with the host. - The app runs as the unprivileged
mlabuser inside the container.
Backup and restore
What a tprm.mlab.sh instance stores and where, the exact backup and restore commands, how to test a restore and what to save before an upgrade.
Sizing and scaling
Resources for a tprm.mlab.sh instance, what grows with use, what can be scaled and what high availability looks like in practice.