Security & isolation
One Postgres database holds many workspaces, and one workspace must never see another’s memory. This page describes what enforces that today, and where it does not apply.
The local Docker stack does not isolate workspaces. It connects to Postgres as the database owner, which bypasses row-level security. Isolation is on in production, where the server connects as a restricted role. See Deploy.
Workspace isolation: row-level security with FORCE
Every tenant table enables row-level security with FORCE, so the policies
apply to the table owner too. A row is visible only when its workspace_id
equals the workspace set for the current transaction. Each transaction sets
that value with set_config('app.workspace_id', ..., true), scoped to the
transaction, so it is released on commit or rollback and cannot carry over to
the next request on a pooled connection. With no workspace set, the policies
match nothing: a query returns zero rows rather than every row.
A role with SUPERUSER or BYPASSRLS skips these policies. Production
closes that gap in two places:
- The app role. With
MNEMO_APP_DB_PASSWORDset, themigrateservice creates the login rolemnemo_appasNOSUPERUSER NOBYPASSRLS. The server connects as that role. - A boot check. The server inspects its own database role at start-up
and exits if the role has
rolsuperorrolbypassrls.MNEMO_ALLOW_UNSAFE_DB_ROLE=truesuppresses the check for local development, and the server refuses to start with it whenNODE_ENV=production.
A workspace can also restrict rows to one end user: the read policy on
mnemo_fact can require actor_id to match the caller. It is off by
default.
Isolation has its own integration tests under a restricted role, for example
collapse-rls-nonsuperuser. docs/guides/DEBUG_RLS_ISOLATION.md in the
repository explains how to check it by hand.
Sensitivity tiers and the key ceiling
Every memory has a sensitivity: public, internal, confidential or
restricted. A memory with none is treated as internal.
Each request has a read ceiling. It is the more restrictive of two values:
MNEMO_SENSITIVITY_CEILING, the process-wide limit.- The key’s own
maxSensitivity, set when the key is created. A key can only lower its ceiling below the process limit, and a key cannot create another key with a higher ceiling than its own.
A read of a memory above the ceiling answers 404, so the caller cannot
tell that it exists. A write above the ceiling is refused with
sensitivity_above_ceiling: its writer could never read it back.
In production, MNEMO_MASTER_KEY encrypts confidential and restricted rows,
and the pull keys and symmetric keys of federation peers.
Encrypted memories
The statement and subject of a confidential or restricted fact are stored
encrypted (AES-256-GCM) under a key of the credential that wrote it. Every
read opens them: the ceiling decides who gets the row, and a caller allowed
to read the tier gets the plain text, through the API, MCP, the dashboard or
an export.
- A row that cannot be opened never comes back as ciphertext. It reads
[erased]withredacted: "erased"once its key was destroyed by an erasure, and[unreadable]withredacted: "unreadable"on a server withoutMNEMO_MASTER_KEY. Recall leaves such rows out;GET /facts/{id}and the listings show them flagged. - Encrypted facts are found by meaning, since the vector is computed from the plain text before the write (unless the embedder may not receive it, see below), and by exact repeat. Full-text search never finds them, on purpose: a full-text index of the plain text would keep its words in the clear.
- The stored vector is not encrypted and survives an erasure. It is derived from the text, so someone with the database can learn something from it.
Which providers see confidential text
MNEMO_SENSITIVE_TEXT_TO_PROVIDERS decides which external providers may
receive the plain text of confidential and restricted memories:
| Value | Embedding provider | Completion provider |
|---|---|---|
none | no | no |
embed (default) | yes | no |
all | yes | yes |
- Under
nonesuch a memory is stored without a vector, so recall finds it only by exact repeat, never by meaning. Nothing embeds it later either: the background re-embedding andPOST /admin/embedding-migrationsthen take onlypublicandinternalrows. - Unless completions are allowed, a confidential write skips the
contradiction check, other writes are checked only against
internaland lower, and recall does not rerank a page that holds one. Underallthose checks reach up to the writer’s ceiling, so contradictions with confidential facts are found. - A local provider is not egress and gets that text under any value: Ollama
with no base URL, or a base URL whose host is
localhostor an IP literal in loopback or a private range (127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,::1,fc00::/7). Any other host name, a compose service such ashttp://ollama:11434included, counts as external, because DNS decides where it goes. When every provider is your own, setall. - Bedrock is always external, and so is a provider a workspace sets with
PUT /config/llm. Each task is judged by the provider it runs on, so ajudgerouted to another vendor is decided on its own. - The value changes nothing else: consolidation leaves confidential and restricted facts out in every case, HyDE and anticipation send only the query, and session collapse sends session turns, which carry no tier.
- A memory with a missing or unknown tier counts as sensitive. Any other value of the variable stops the server at boot.
API keys
Keys are hashed with bcrypt before they are stored. The plaintext key is
shown once, at creation. MNEMO_KEY_PEPPER, required in production, keys the
HMAC-SHA256 lookup hash stored next to the bcrypt hash.
A key authenticates the caller and selects the workspace: a client never
sends a workspace id. A key carries scopes, such as memory:read,
memory:write and memory:hard_delete, and can carry an expiry and an IP
allowlist of CIDR ranges. An empty scope list is rejected unless
MNEMO_ALLOW_LEGACY_FULL_SCOPE=true, which the local override sets.
Manage keys with mnemo keys list|create|revoke|show|rotate or the
/admin/keys routes. Rotation keeps the old key working for 7 days.
MNEMO_SCOPED_AUTH=1 turns on a second key scheme, in beta, whose keys are
checked against their own table. The keys /admin/keys mints keep working
with it on.
The server issues those keys itself, with the same admin:keys scope and the
same limits as /admin/keys: no scope and no ceiling the caller does not
hold.
| Action | Route | CLI |
|---|---|---|
| Issue | POST /admin/scoped-keys | mnemo keys scoped create |
| Rotate | POST /admin/scoped-keys/{id}/rotate | mnemo keys scoped rotate |
| Revoke | DELETE /admin/scoped-keys/{id} | mnemo keys scoped revoke |
typeislive(mk_live_, 90 days at most),sess(mk_sess_, 24 hours at most) oradmin(mk_admin_, 24 hours at most).expiresInasks for less, as in8h.- The key is bound to the user who issued it and shown once. Issuing works with the flag off, so keys can exist before you turn verification on.
- An
mk_admin_key is issued only to a caller with a user. Its TOTP secret is returned once, in base32 and as anotpauth://URI, and every request with the key sends a current code inx-mnemo-mfa. Only its user may rotate it. - Rotation leaves the old key working for 7 days; revocation is immediate.
{id}is{prefix}{keyId}, and a key of another workspace answers404. - The TypeScript client has
issueScopedKey,rotateScopedKeyandrevokeScopedKey. gRPC refuses these keys.
PII redaction on write
POST /remember redacts personal data from a statement before it is stored.
The layer is a set of regular expressions over these categories:
| Category | Severity |
|---|---|
api_key | 1.00 |
credit_card | 0.95 |
ssn | 0.95 |
url_with_token | 0.85 |
phone | 0.55 |
email | 0.50 |
ip_address | 0.30 |
Each match is replaced with [REDACTED-<category>]. The response returns the
statement as it was stored, plus redactedCategories when something was
removed. The original text is not kept.
The patterns are conservative and miss things on purpose. Treat the layer as a first line of defence, not as a guarantee.
Audit log, approvals and webhooks
- Audit log. Security-relevant actions are written to
mnemo_audit_log. Entries are hash-chained (SHA-256 over the previous hash and the entry), so a changed or removed entry breaks the chain. - Approvals. Some actions need a second person. A gated request answers
202with an approval id; another user resolves it withPOST /approvals/{id}/resolve, and self-approval is rejected. A bulk export is one of them. - Webhooks. Every delivery is signed with HMAC-SHA256 over the timestamp
and the body. The signature travels in the
Mnemosyne-Signatureheader ast=<unix seconds>,v1=<hex>.
More on each in Security & compliance.
Reporting a vulnerability
Do not open a public issue. Use GitHub private vulnerability reporting on the
repository: Security, then “Report a vulnerability”. SECURITY.md in the
repository has the details.