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

PrincipalInterfaceMay
A superuserThe API, with a passwordEverything: databases, users, deployment-wide keys, limits, restores, fences, quarantine
A user or deployment-wide key with a roleThe administration APIThe deployment permissions its roles name (below)
A user with a grant, or a database keyThe HTTP API and /v1/adminIts permission (read, write or admin) on its database
A document tokenThe HTTP API and sessionsread or write on one document, until it expires
Whoever holds a store's PostgreSQL credentialsmimicd admin, or PostgreSQL itselfEverything, 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:

PermissionAllowsobserverbackup_operatorstore_operatorauditor
status.readThe deployment's status and settingsyesyes
stores.readThe stores, and store operations read backyesyes
stores.writeStore operations started and cancelled (moves, a store's drain)yes
databases.listDatabases listed, and each one's record and removal readyesyesyes
databases.readDatabases' limits and access modes, budget groups' and the default limitsyesyes
usage.readThe usage feedyesyes
operations.readOperations listed, each only if its kind's read permission is held tooyesyesyes
backups.readA database's backups listed and read, backup operations read backyesyesyes
backups.writeBackups started, read back again, and expired through the server's guardsyes
audit.readThe audit trailyes

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

SecretWhere it lives
Store credentialsMIMIC_POSTGRES_URL and MIMIC_STORE, the configuration file, PGPASSWORD or a PGPASSFILE
The bootstrap passwordA file, or MIMIC_BOOTSTRAP_PASSWORD; only its hash is stored
The internal secretA file, the same on every process; random bytes, never a password
Sealer keysA keys file, the same on every process, in a secret store with an offline copy
Backup destination accessThe 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 = aead encrypts them with XChaCha20-Poly1305 under the key sealer_primary_key names, 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_writes and synchronous_commit on, 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_origins and gateway.trusted-proxies exact.
  • backup_destination set, in another account or host, with object lock or versioning; sealer_mode = aead with keys in a secret store and an offline copy, then sealer_open_clear = no; restores tested.
  • A default limits record, and limits for tenants not fully trusted.
  • Migration sandboxes filtered, and no --migrations.allow-unfiltered-sandbox where 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.