Security
Who may do what, deployment roles, what operator commands can reach, secrets, sealing at rest, migration sandboxes, and a hardening checklist.
This page describes the security model of a deployment and how to harden one.
Who may do what
| Principal | Interface | May |
|---|---|---|
| A superuser | The API, with a password | Everything: databases, users, deployment-wide keys, limits, restores, fences, quarantine |
| A user or deployment-wide key with a role | The administration API | The deployment permissions its roles name (below) |
| A user with a grant, or a database key | The HTTP API and /v1/admin | Its permission (read, write or admin) on its database |
| A document token | The HTTP API and sessions | read or write on one document, until it expires |
| Whoever holds a store's PostgreSQL credentials | mimicd admin, or PostgreSQL itself | Everything, and more: every row of the store |
See Authentication and access and Administration.
- Database key secrets are kept as SHA-256 digests, shown once when the key
is created. Passwords are kept as PBKDF2-SHA256 hashes, at
password_iterations(600,000 by default). - A revoked key or grant, a disabled user or a changed password takes effect
within
access_max_staleness_ms(10 seconds by default). A process that cannot tell whether a credential is still valid refuses it. - A credential is never accepted in a URL.
Deployment roles
A deployment role lets an automation observe the deployment, take its backups, move its stores or read its audit trail without holding a superuser. None reaches a document, a credential or access data. A superuser grants roles to users and to deployment-wide keys:
| Permission | Allows | observer | backup_operator | store_operator | auditor |
|---|---|---|---|---|---|
status.read | The deployment's status and settings | yes | yes | ||
stores.read | The stores, and store operations read back | yes | yes | ||
stores.write | Store operations started and cancelled (moves, a store's drain) | yes | |||
databases.list | Databases listed, and each one's record and removal read | yes | yes | yes | |
databases.read | Databases' limits and access modes, budget groups' and the default limits | yes | yes | ||
usage.read | The usage feed | yes | yes | ||
operations.read | Operations listed, each only if its kind's read permission is held too | yes | yes | yes | |
backups.read | A database's backups listed and read, backup operations read back | yes | yes | yes | |
backups.write | Backups started, read back again, and expired through the server's guards | yes | |||
audit.read | The audit trail | yes |
A role is no part of a credential: changing one leaves its holder's sessions and password as they were, and a role revoked is refused from the next request on. See Administration.
Operator commands reach the store
mimicd admin connects to PostgreSQL, not to a process. There are no
operator certificates: whoever holds a store's credentials can do what any
command does, and more. The audit trail records an operator command's
actor as operator:<name>, from MIMIC_OPERATOR_NAME or the system's user
name: stated, not authenticated. Prefer the administration API with a
deployment role for anything automated, and keep the stores' credentials to
the processes and the people who run them.
Secrets
| Secret | Where it lives |
|---|---|
| Store credentials | MIMIC_POSTGRES_URL and MIMIC_STORE, the configuration file, PGPASSWORD or a PGPASSFILE |
| The bootstrap password | A file, or MIMIC_BOOTSTRAP_PASSWORD; only its hash is stored |
| The internal secret | A file, the same on every process; random bytes, never a password |
| Sealer keys | A keys file, the same on every process, in a secret store with an offline copy |
| Backup destination access | The environment of every process (AWS_ACCESS_KEY_ID, an instance role, …), never the URL |
Secrets never come from flags, and never appear in logs or metrics;
mimicd serve --check prints passwords redacted.
Sealing at rest
The deployment's sealer protects what backups write, and what the deployment keeps of its own secrets in its store (webhook endpoints' signing secrets and header values, ACME's keys):
sealer_mode = digest(the default) writes backup objects in the clear, each bound to its database and place by the SHA-256 its backup's manifest records, so an object planted or changed is found when it is read.sealer_mode = aeadencrypts them with XChaCha20-Poly1305 under the keysealer_primary_keynames, from the keys file every process is given (--sealer.keys-file). Backup manifests are never sealed, so anyone who can read the destination can check a backup without a key.
See Backups and restores for the keys file and rotating keys. PostgreSQL's own data is PostgreSQL's to encrypt at rest (your provider's, or the disk's).
Migration sandboxes
Schema migrations are code a database's administrators push. They run in
sandbox processes of the binary itself. On Linux a sandbox runs under a
system-call filter (seccomp) that refuses every socket and, where
unprivileged user namespaces are allowed, in a network namespace of its
own. A sandbox that could not install its filter is refused, and migration
runs answer unavailable, unless the process runs with
--migrations.allow-unfiltered-sandbox: fit only where every database's
administrators are trusted with the whole deployment. Other platforms
(macOS) run sandboxes without either, for development.
The process logs the isolation it got once; /status (migration_sandbox)
and mimic_migration_sandbox_isolation show it.
Webhooks
Triggers deliver webhooks only to https endpoints at public addresses.
--triggers.allow-cidrs names private ranges they may reach besides;
--triggers.allow-http lifts both rules, for development only.
Tenants
Processes serve many databases and keep them apart by identity, admission and checks, not by hardware. Set limits for tenants you do not fully trust (see Limits); give a tenant that needs a hard boundary a store, or a deployment, of its own.
Hardening checklist
- PostgreSQL with
fsync,full_page_writesandsynchronous_commiton, data checksums on, a synchronous standby in another zone, and its WAL archived for point-in-time recovery. - Stores reached over TLS (
sslmode=verify-full) by a role that is no superuser, the same role for every process; credentials in variables or files, never flags. - The internal listener on a private network, authenticated by a random secret or your own certificates with a peer name; the operations listener private.
- TLS for clients;
cors_originsandgateway.trusted-proxiesexact. -
backup_destinationset, in another account or host, with object lock or versioning;sealer_mode = aeadwith keys in a secret store and an offline copy, thensealer_open_clear = no; restores tested. - A default limits record, and limits for tenants not fully trusted.
- Migration sandboxes filtered, and no
--migrations.allow-unfiltered-sandboxwhere a database's administrators are not trusted with the deployment. - Automation through the API with deployment roles, not the stores' credentials.
- NTP on every host and every PostgreSQL server.
- Alerts on every alert the processes log (
mimic_alerts), on attention items, on readiness, and on the stores' disk and replication.
Reporting a vulnerability
Report suspected vulnerabilities privately, through "Report a vulnerability" under the Security tab of the repository, not in a public issue or pull request. Include the version or commit, the configuration that matters, steps to reproduce, and the impact you expect.