1. Threat model
milliMind aims to protect journal content from Cloudflare storage operators, the milliMind server operator (including the developer), a database compromise, network interception, and opportunistic access to a device by another person, including someone who knows the device passcode.
The sync server is treated as untrusted for confidentiality, key distribution, device membership, and the completeness of the change log. A malicious or compromised server must not be able to:
- read content or learn record types;
- add a device, or cause key material to be wrapped to a key it controls;
- silently drop, reorder, replay, or roll back records (including deletions) without detection.
Out of scope, and stated as such in Limitations: a compromised or unlocked endpoint, malware, metadata that cannot be hidden, an external model the user chooses to enable, and the integrity of the shipped client binary itself.
2. Key hierarchy and epochs
Keys are organised in numbered key epochs. Each epoch has an independently generated, random 256-bit epoch root key and a random 256-bit epoch Session key. Epoch 1 is created on the first trusted device.
- Domain-separated content keys. Within an epoch, content keys are derived from the root key with HKDF, using distinct info labels that include the epoch number: journal records, derived records, device-list details, checkpoints, and the job-key HMAC each get their own key. A key compromised or misused in one context is useless in another, and no key is ever used for two purposes.
- The Session key is not derived from the root key. Therapy Session Mode records use it. Because it is independent, a device holding the background-tier root key still cannot decrypt Session content locally without the strict-tier key (§8).
- Device identity keys. Each device has a P-256 signing key and a P-256 key-agreement key, held in the Secure Enclave where available, otherwise in the keychain. Epoch keys move between devices only as encrypted envelopes wrapped to a key-agreement public key; Secure Enclave private keys never leave the hardware.
Rotation: always random, never derived
A new epoch's keys are freshly generated, never derived from the previous epoch. A device that held epoch N therefore learns nothing about epoch N+1. Rotation happens:
- with every device revocation (mandatory, immediately after the
revokeDeviceentry); - when the recovery secret is rotated because exposure is suspected;
- when the user taps Rotate keys now.
There is no scheduled rotation. Periodic rotation only helps against an undetected key theft, and never protects data already written; we chose not to add the complexity for that narrow gain.
- A trusted device generates the new root and Session keys.
- It appends a signed
rotateEpochentry to the device list, carrying the epoch number and a key commitment (an HMAC of a fixed label under the new key), so every device can confirm it received the right key without the key being revealed. - It wraps the new keys to every device authorised in its locally verified device list (never a list supplied by the server), and rewraps the recovery envelope.
- It publishes a key-history envelope: all earlier epoch keys, encrypted under the new epoch. Devices paired later receive only current-epoch keys and unlock history through it.
After processing a rotation, a device writes only under the newest epoch. Each envelope's encrypted payload records the device-list head its author had seen, and an envelope under an older epoch is rejected if that head already includes a newer rotation.
3. Record encryption
- AES-GCM (CryptoKit
AES.GCM) with a unique nonce per envelope. - Associated data binds the envelope header, including
keyEpoch, plus the account ID. Ciphertext cannot be moved to a different header, epoch, or account without failing authentication. The two server-assigned fields,serverSeqandreceivedDay, are excluded because the client cannot know them in advance. - Encrypt-then-sign. The author device signs header + ciphertext with its device signing key. Holding the shared content key is not enough to forge a record from another device, so authorship is provable.
- Plaintext epoch or content keys are never sent to the server, and secrets are never logged.
4. Size padding and upload batching
Padding. Plaintext is padded before encryption to buckets of 1, 2, 4, 8, 16, 32, and 64 KiB, then multiples of 64 KiB. Most entries fall in the 1 KiB bucket, so a short note and a long paragraph look identical. Larger objects are split into fixed-size encrypted chunks.
Batching. The outbox uploads in batches: when the app moves to the background, and about every 5 minutes in the foreground, with up to 2 minutes of random jitter. This hides per-entry timing and how many entries are in a batch.
Honest limit: there is no cover traffic, so batching does not hide when you use the app. The server sees request times as they happen.
5. Envelope format: what the server sees
Every synced record, whether a journal entry, deletion tombstone, memory, Session record, setting, or job result, is an opaque envelope. Record types and relationships live only inside the ciphertext, so the server cannot tell one kind from another.
| Server-visible header | Inside the ciphertext only |
|---|---|
envelopeID (random, unrelated to the record ID) | recordID |
serverSeq (assigned by the server) | recordType |
authorDeviceID | schemaVersion |
deviceSeq (per author, monotonic) | createdAt / committedAt |
prevEnvelopeHash (author's previous envelope) | Tombstone flag and deletion scope |
keyEpoch | Revision, supersedesID, hybrid logical clock timestamp |
nonce, padded ciphertext, signature | Payload |
receivedDay (day granularity only) |
6. Signed device list
Which devices belong to your account is decided by an append-only, hash-chained log that your devices create and sign. The server stores and relays it but cannot author it.
- The genesis entry is self-signed by the first device and contains its public keys and the recovery signing public key.
- Later entries (
addDevice,revokeDevice,rotateEpoch,rotateRecovery) carry a sequence number, the previous entry's hash, and a signature from a device authorised at that point, or from the recovery key. - Only device IDs and public keys are in the clear; names, models, and capabilities are encrypted.
- Each device pins the latest verified head and rejects any list that doesn't extend it. A fork or rollback raises a security alert and is never auto-resolved.
- Keys are wrapped to, and records accepted from, only devices present in the locally verified chain. A server-supplied device, authorisation state, or public key outside that chain is ignored.
- A
revokeDeviceentry records the lastdeviceSeqaccepted from that device; anything later is rejected.
Sign in with Apple tokens grant access to encrypted records but never confer device membership, so a stolen or forged session token cannot add a device.
7. QR-only pairing
Pairing requires both devices to be physically together and a camera scan. Numeric or word comparison codes, email links, and server-mediated approval are deliberately not supported: each would either rely on a human comparing codes correctly or give the server a role in deciding membership.
- The new device signs in, generates its key pairs, and registers a pending pairing request (public keys only).
- One device shows a QR code; the other scans it, in whichever direction has a usable camera. The QR payload holds the protocol version, request ID, the displaying device's ID and public keys, a fresh 256-bit one-time pairing secret, and an expiry of at most 5 minutes.
- All further messages relayed through the server are encrypted and authenticated with keys derived from that secret, using HPKE in PSK mode. The server can neither read nor forge them, and any public-key substitution is detected.
- The trusted device shows the new device's name and model and requires explicit confirmation plus reauthentication.
- It appends a signed
addDeviceentry and sends the wrapped epoch keys and key-history key, with the current device-list head hash, over the pairing channel. - The new device verifies the full chain against that head, pins it, and only then starts syncing.
Pairing secrets are single-use, short-lived, and never sent to the server. Successful, failed, and expired attempts are written to an encrypted audit record shown on trusted devices.
8. Keychain tiers, Strict Mode, and the milliMind passcode
The app lock is enforced by keychain access control, not only by UI. Bypassing the lock screen (for example on a jailbroken device) does not yield the keys the lock protects. Lock state is local to each device.
| Tier | Contents | Keychain protection | Background use |
|---|---|---|---|
| Background | Epoch root keys and derived keys for ordinary journal and derived records; device identity keys needed for sync | kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly |
Yes |
| Strict | Session keys (all epochs); with Strict Mode on, all content keys | kSecAttrAccessibleWhenUnlockedThisDeviceOnly + SecAccessControl user presence (.userPresence, or .biometryCurrentSet for biometrics only) |
No |
- Why two tiers
- Background sync, indexing, and on-device inference need keys while the app isn't in front of you. The background tier makes that possible, at a documented cost: those keys are available whenever the device has been unlocked once since it started up. Session Mode content always uses the strict tier, whatever the settings.
- Strict Mode
- Optional and off by default, in Privacy settings. All content keys move to the strict tier. Encrypted upload and download continue while locked (already-encrypted items upload; downloaded ciphertext is stored and applied after unlock), but background decryption, indexing, and inference pause. Reflections and reminders then run only while the app is open and unlocked.
- milliMind passcode
- An optional app-specific passcode implemented with the
.applicationPasswordaccess-control flag, so it is cryptographically bound to the strict-tier keys. It replaces device-passcode fallback, so knowing the device passcode is not enough to open the app. A forgotten milliMind passcode is recovered by re-obtaining keys from another trusted device or the recovery secret, then setting a new one. - No backups, no migration
- Every keychain item is
ThisDeviceOnly: excluded from device backups and never migrated to a new device. On macOS, milliMind always uses the data protection keychain (kSecUseDataProtectionKeychain), never the legacy file-based login keychain.
9. Recovery secret
- Always app-generated: 256 bits from the system CSPRNG, shown as a word list or grouped Base32 with a checksum. It can never be a user-chosen password or PIN. The recovery envelope is stored on the server, so a guessable secret could be brute-forced offline by whoever runs the server; a 256-bit random secret cannot.
- A recovery key-encryption key is derived with HKDF (its own domain). The recovery envelope wraps the current epoch keys and the key-history key, and is rewrapped on every rotation.
- A recovery signing key is derived in a separate HKDF domain; its public key sits in the genesis entry. When no trusted device remains, it signs the
addDeviceentry for the recovering device, which then triggers a rotation. - The secret can be rotated (
rotateRecovery, with a key rotation if exposure is suspected), and old recovery envelopes are revoked. - Onboarding includes a verification exercise; it can be repeated later.
If all trusted devices and the recovery secret are lost, neither the developer nor Cloudflare can restore the journal.
10. Server as untrusted relay
The server (Cloudflare Workers and D1, with R2 for larger encrypted objects) is an append-only store and relay. It is authoritative for the order of the encrypted log, never for plaintext meaning, device membership, or conflict resolution.
- There are no server-side "approve" or "revoke" endpoints. Approval and revocation are signed device-list entries.
- The server checks signatures, chain continuity, and per-device
deviceSeqon append as defence in depth; clients always verify independently. - Conflicts on mutable records (settings, memory status) are resolved on clients, with hybrid-logical-clock last-writer-wins or per-type merge rules, because the server cannot see record identity.
- Client-directed compaction: a device publishes a signed list of envelope IDs safe to delete; the server deletes only those.
- Server responses are data validated against schemas, never instructions that change client security behaviour.
11. Completeness and rollback detection
Encryption alone doesn't stop a server from hiding records. Every envelope belongs to its author device's hash chain (deviceSeq, prevEnvelopeHash), and each device keeps a checkpoint per author: the highest verified deviceSeq and its hash. On every pull a device:
- verifies the author is authorised in the verified device list and the signature is valid;
- verifies chain continuity, refetching on a gap; a gap that persists raises a withholding alert;
- treats the same
deviceSeqwith a different hash as a fork alert; - never silently applies a record that fails these checks.
- Signed checkpoints. Each device periodically publishes an encrypted, signed checkpoint listing the latest
deviceSeqand hash it has seen from every device, so a server withholding the tail of one device's chain is caught by the others. - Deletions can't be hidden. Tombstones are signed chain records, so withholding one leaves a detectable gap. A new or restored device verifies all chains before presenting content as complete.
- Replays. An already-seen (
authorDeviceID,deviceSeq) is ignored, and old revisions can't override newer ones because ordering lives inside the authenticated payload. - Revoked devices. Records past a device's revocation cutoff are rejected.
12. Local database
On device, milliMind stores your journal in SQLite via GRDB, encrypted with SQLCipher Community Edition (using Apple's CommonCrypto), pinned to an exact version.
- The database key is 32 random bytes used as a raw key, with no password-based derivation, and follows the keychain tiers above.
- Temporary storage is kept in memory, and the database file, write-ahead log, and full-text index are all encrypted. Deleted content is also overwritten: SQLite’s
secure_deletezeroes freed pages, and the full-text index’ssecure-deleteoption removes a deleted entry’s words immediately instead of leaving them in old index segments. - The database directory is excluded from device backups and, on iOS, uses
completeUntilFirstUserAuthenticationfile protection. - Search indexes are rebuilt locally on each device rather than synced.
OS Data Protection, FileVault, and the keychain are complementary layers, not substitutes for database encryption.
13. Platform data-exposure controls
Some system features could carry journal text outside milliMind's encryption, so they are disabled or constrained:
- Third-party keyboards (iOS/iPadOS) are refused via
shouldAllowExtensionPointIdentifier, because a keyboard with Full Access can log everything typed. The system keyboard is always used. - Writing Tools / Apple Intelligence are disabled on every view that edits or displays journal content, since they can send text to Private Cloud Compute or the ChatGPT integration.
- Handoff and activity donation: no journal text, or IDs or titles that reveal content, in
NSUserActivity; Handoff, search, and prediction eligibility are off. - Spotlight: no indexing of journal or derived content.
- Siri, Shortcuts, App Intents: one Quick Capture intent (Action Button, Shortcuts, Control Center) only opens the app to write; it takes no text, returns nothing and is never donated. While milliMind is locked, Quick Capture is write-only: each capture is sealed with HPKE (X25519) to a device inbox public key, and the private key sits in the same keychain tier as the database key, so the locked app can save new thoughts but cannot read anything, including its own earlier captures. On unlock the inbox is opened and committed with original timestamps.
- Pasteboard: in-app copy is
localOnlywith a short expiration, so it doesn't reach Universal Clipboard. - App switcher snapshots are covered, notifications are generic by default, and plaintext exports require reauthentication.
14. Inference and AI providers
- Inference runs on device by default (Apple's on-device model where supported), always after an entry is committed. Unsupported hardware still gets full capture, sync, search, and export.
- No journal content is sent to an external model without explicit opt-in and a clear disclosure of the provider and the data transmitted.
- Inference work shared across your devices is coordinated through leases. The server sees only an opaque job key (an HMAC of the job identity under an epoch-derived key, so duplicates are recognised without revealing the task), lease and fencing tokens, expiry, status, and an encrypted job descriptor. Device capability heartbeats are encrypted records, and devices choose among themselves.
- Model output is validated against schemas before it's stored, and every memory or reflection links to the entries that support it.
15. Residual metadata
Even with all of the above, the server observes:
- account identity via Sign in with Apple (possibly a relay email address);
- device IDs and public keys;
- IP addresses and request times;
- bucketed sizes and batch counts;
- inference job lease activity;
- subscription entitlement state;
- day-level receipt dates.
Workers request and body logging, Logpush, and analytics beyond what abuse prevention needs are disabled. Headers, ciphertext, and tokens are never logged, and operational logs are short-retention. D1 point-in-time recovery (Time Travel) and other backups retain deleted ciphertext for their retention window, as stated in the privacy policy.
16. Client integrity and developer trust
End-to-end encryption protects data from the server, not from the code running on your device. Whoever controls the signed app binary (the developer, someone who compromises the developer account or build pipeline, a malicious dependency, or a party compelling an update) could ship code that exfiltrates keys or plaintext. This cannot be eliminated cryptographically. The goal is that accessing user data would require shipping a modified build to every user, publicly and detectably.
No targeted or silent changes
- No remote configuration, feature flags, A/B tests, downloaded scripts, or dynamic code loading can affect cryptography, key handling, the device list, what data is sent, or where it is sent. Security-relevant behaviour changes only with a new app release.
- TestFlight builds, which can be targeted at individuals, are used only with test accounts, never real journals.
- No web client can decrypt journal content. This website is marketing and documentation only.
Minimal, auditable client
- One small network module talks to one sync domain through an allowlist of endpoints. No other code path opens network connections with journal-derived data.
- No third-party analytics, advertising, or crash-reporting SDKs. Only Apple's built-in diagnostics, with no journal content in logs.
- Minimal third-party dependencies, pinned to exact versions, reviewed on update, and tracked in a software bill of materials.
- The security core, MindCore (
MindCrypto,MindSecurity,MindSync,MindAPI), is open source under Apache-2.0. It has no third-party dependencies, imports no closed modules, and onlyMindAPIdoes networking; a boundary check enforces this in CI and before every release.
Release integrity
- Hardware security keys protect the Apple Developer, App Store Connect, GitHub, and Cloudflare accounts, with no SMS fallback.
- Releases are built and uploaded by CI from tagged commits with pinned toolchains and dependencies, not from a personal machine. Signing credentials live only in CI.
- Release notes, the commit/tag, and build hashes are published for every shipped version.
- An independent security audit is part of the plan before public launch and after major cryptographic changes, with the report published.
- milliMind will not knowingly ship a build designed to weaken encryption for any user, and publishes a transparency report.
17. Limitations
We'd rather you hear these from us:
- Unlocked or compromised devices. Anyone with your unlocked device, or malware on it, may see your journal. Encryption protects data in transit and at rest, not on a screen someone else is looking at.
- Background-tier keys are available whenever the device has been unlocked once since boot. Turn on Strict Mode if you prefer keys to require authentication, at the cost of background reflections and reminders.
- Revoked devices keep whatever they had already downloaded, and rotation protects only future content. Old ciphertext remains readable to anyone holding old keys and a copy of server data, unless you run history re-encryption, and even then server backups keep old ciphertext for their retention window.
- Metadata. Usage times, IP addresses, approximate sizes, batch counts, day-level dates, device IDs, and account identity are visible to the server (§15). Batching hides per-entry timing, not when you use the app.
- Delayed records. The server can delay the newest records until a later checkpoint reveals the gap.
- Lost devices and recovery secret. If you lose all trusted devices and your recovery secret, your journal cannot be recovered by anyone.
- The milliMind passcode is protected by the keychain, but we make no claim about how many guesses the system allows. Choose a passcode that isn't easy to guess.
- Mac input. macOS has no way to refuse third-party input methods, and apps you have granted Accessibility permission can read on-screen text.
- System Copy. The system text-selection Copy command can still reach Universal Clipboard. milliMind's own copy actions are local-only, and the system command is overridden in journal views where feasible.
- Apple Reminders. Reminders milliMind creates live in Apple Reminders and sync according to your Apple settings, outside milliMind's encryption.
- External AI. If you opt in to an external AI provider, the text you send is processed under that provider's terms.
- Exports. Markdown and PDF exports are unencrypted files once you save or share them; milliMind warns you when writing them.
- Client integrity. Your security depends on the integrity of the app itself (§16).
18. Reporting a vulnerability
Please report security issues privately through GitHub private vulnerability reporting on the MindCore repository. Please don't include real journal content in a report.