Skip to content

Security model

Please open a private security advisory rather than a public issue.

NIDO_MASTER_KEY is the root of the whole system, and it is unforgiving in two directions.

  • It is unrecoverable. Lose it and every family database is lost, with no error to signal it and no recovery path.
  • It cannot be rotated. Every family key is an HKDF-SHA256 subkey derived from it. Change the key and every existing database becomes undecryptable immediately.

Choose it once, before real data exists, and back it up separately from the data volume. A copy of the key sitting on the same disk as the data protects you from nothing.

There is deliberately no default and no fallback key. The API resolves NIDO_MASTER_KEY and JWT_SECRET before binding a port, so a misconfigured process exits rather than serving traffic under a key that is published in the repository.

Data At rest
registry.db SQLCipher, keyed by a nido:registry subkey
db/<familyId>.db SQLCipher, keyed by an HKDF subkey derived from that family id as salt
Session tokens Signed JWTs, 30-day expiry
Photos Not encrypted on disk

The encrypted file is the tenant boundary. There is no WHERE family_id = ? filter inside a family database because there is no need for one — see Architecture → the tenant boundary.

Concern Rule
familyId Attacker-influenceable and used to build a filesystem path. Must pass assertFamilyId() / ^[A-Za-z0-9-]{10,64}$ before touching the filesystem or a SQL string.
Authorization Lives in authz.ts, before getFamilyClient(). Not in a query, not after.
SQL Parameterized only. No request-derived string is ever concatenated into SQL.
Request bodies Validated with zod before any database access.
Files MIME-validated and scoped by blobs.family_id. Client-supplied filenames and paths are never trusted.

Settings → Agents → Agent access mints opaque tokens (nido_mcp_…) that connect an AI agent you run to one family over MCP. The registry stores only a SHA-256 hash with the family id and a label — the plaintext is shown once and never persisted or logged.

A token resolves to exactly one family, so every request opens only that family’s database; a tool cannot widen its scope. Unknown and revoked tokens get the same answer, so there is nothing to probe. Tokens carry no scopes and never expire — revoking is the control, and access ends at the next request. Requests are rate-limited per token.

  • NIDO_MASTER_KEY generated with openssl rand -hex 32 and backed up off the data volume
  • JWT_SECRET generated independently of the master key
  • .env at mode 0600; never committed
  • SIGNUP_ENABLED=false once the family is invited
  • ADMIN_EMAIL set, so admin is not whoever registers first
  • PUBLIC_URL set to the real public origin, not localhost
  • ALLOWED_HOSTS set to the public hostname if behind a proxy
  • TLS terminated in front of Nido
  • Port 3000 not exposed to the internet — single-origin setup, or bind to 127.0.0.1
  • Automated volume backups running, with the key stored separately
  • A restore has been tested, not merely written
  • Request body size capped at the proxy, pending the upload limit

Nido assumes the host it runs on is trustworthy and the network in front of it is not. It encrypts the most sensitive thing — a family’s feeding, sleep and health records — at rest with a key the operator controls, and it treats authorization as a property of which file gets opened rather than of a WHERE clause. It does not attempt to be hardened against a determined attacker with shell access on the host, and it is not a medical device. A VPN is a better front door than a hardening exercise.

Apache-2.0.