Security
Content is encrypted end-to-end on the client, and authorization is cryptographically verifiable: clients derive encryption targets from signed principal policies and access manifests, and verify write commitments and access paths locally before trusting synced state.
This page summarizes the implemented security architecture. The technical documentation defines the verification rules, formal models, operational limits, and residual boundaries in detail.
Threat model
The sync API and its backing storage sit outside the trusted computing base for content confidentiality and authorization integrity.
These guarantees assume an honest, uncompromised client that executes its verification gates without suppressing errors, uncompromised user signing and key-encapsulation private keys, authentic user identity bindings, and standard security assumptions on the underlying cryptographic primitives.
If the API or its storage becomes compromised, the service still holds no plaintext content, container, or principal keys, and an honest client detects and rejects forged or tampered authorization state rather than trusting server projection rows(the database's denormalized lookup tables). Under the assumptions above, client-side verification fails closed against adversarial server behavior, including:
- Unauthorized target injection: serving forged recipient lists, altered membership projections, or substituted pinned public keys to make a client encrypt keys or content for unauthorized principals
- Invalid access-plane mutations:honoring unsigned or forged access events, container grants, parent moves, document links, or attachment bind events, orprincipal-policyshrink transitions that reuse an earlier key epoch
- Projection-row tampering: editing server-side group or grant lookup tables to authorize key targets without matching signed state roots and hash chains (altered roster or listing rows can still distort directory views, not verified recipient sets)
- Ciphertext and key-envelope tampering: altering encrypted payloads, swapping context-bound content-key wraps across objects or epochs, substituting container keys that miss their signed epoch commitments, or forging content-write headers
- Observed-state rollback and equivocation: serving older policy or manifest heads below a device's recorded checkpoints, or presenting conflicting forks of history the device has already verified
Compromised-server detection covers unauthorized mutation and tampering, not every server misbehavior: a malicious service can still withhold data or deny service, replay older valid signed state (or records signed by a since-revoked member under valid historical authority) to a device that has not observed newer state, present split views across devices without independent witnessing, or substitute identity keys on unanchored first contact. Those residual boundaries are defined under Trust boundaries.
Access plane and keying
Authorization state is derived from signed events into deterministic access manifests. Permission checks walk upward from a resource to its principals; key unwraps traverse the verified graph downward from user or group keys to content.
The authorization graph draws on Google's Zanzibar: permissions are expressed as relationships, and evaluation walks upward from the target resource. A file (blob) is reachable through active signed attachment bindings to documents, a document through its signedlink-set manifest(the signed record of which folders it belongs to) to every container (an Explorer folder) it is linked into, and a container through signed parent edges up to an organization root. Additive grants at different depths of the container hierarchy compose without per-document or per-blob recipient fanout.
Unlike server-authoritative Zanzibar, clients never accept a server check verdict or mutable database projection on trust. The API enforces authorization on reads and writes, while every client independently verifies the signed event chains, deterministic manifest hashes, and referenced principal-policy heads before decrypting or deriving encryption targets, using a fixed relationship schema rather than user-defined rewrite rules. Key encapsulation mirrors that verified graph in reverse: user and group keys unwrap container key-encryption keys (KEKs), parent KEKs derive keypairs that unwrap child container KEKs, and linked container KEKs unwrap document and blob content keys.
Confidentiality and metadata boundary
At-rest encryption protects local state on your device; end-to-end encryption keeps payload plaintext and content keys outside the sync service, while structural and operational metadata remain visible to the server.
Keys are unwrapped and content is decrypted locally.
Unlock the local keyring
Each storage scope wraps a random root key under a host wrapping key, optionally outer-wrapped with a PIN-derived key.
Derive domain-separated keys
HKDF-SHA256 derives independent keys for SQLite, the local file store, and persisted identities.
Encrypt local storage at rest
Reads and writes pass through ChaCha20-encrypted SQLite and chunked AES-256-GCM file storage.
The unlocked client can read plaintext keys and content.
The API stores and indexes ciphertext, wraps, and signed state.
- Encrypted payloads
- AES-256-GCM document updates, file payloads, and encrypted metadata.
- Wrapped key envelopes
- ML-KEM-1024 and AES-256-GCM key wraps that only authorized holders can open.
- Signed authority records
- ML-DSA-87 principal policies, access events (and derived manifests), and write headers.
Holds no plaintext content, container, or principal keys.
Encrypted end-to-end
- Document updates and file (blob) payloads
- Container metadata documents, including folder names
- Organization names and custom group names
- Wrapped content keys, container KEKs, historical KEK keyrings, and principal secret keys
Decrypting these artifacts requires an authorized private encapsulation key, principal secret key, or unwrapped container or content key.
Visible to the service
- Reserved built-in group roles (
AdminsandMembers) - Roster lifecycle rows and group membership projections
- Object-graph topology: folder parent edges, signed system-folder slots (such as an organization's Trash folder), document-to-folder links, and attachment bindings
- Object and principal identifiers, public keys, and key fingerprints
- Signed principal-policy headers, container-grant sets, and key-epoch counts
- Signer user IDs, signing-key fingerprints, and signed timestamps on policies, access events, and writes (plus signer device IDs on access events and writes)
- Version-vector and sequence metadata that order document updates
- Ciphertext lengths, part checksums, and storage consumption
- Connection IP addresses, session and activity timestamps, and the registration IP address
- Subscription and billing records, including the billing email for web subscriptions
Payload encryption does not conceal this structural metadata or network traffic patterns such as request timing and size.
Verified sharing
A container binds content keys to signed access rules. Clients derive recipient key targets strictly from verified access manifests and signed principal policies—mutating a server-side membership or grant lookup row cannot authorize a new recipient.
Verify targets
Verify signed access manifests, referenced principal policies, pinned identity bundles, and local checkpoints.
Encrypt and wrap
Encrypt payloads with per-record keys, wrap content keys to container KEKs, wrap KEKs to verified recipients, and sign write headers.
Validate and persist
Re-verify signatures, lineage, and target commitments inside transactions; store ciphertext and wrapped envelopes.
Verify and decrypt
Independently verify signed policies, manifest paths, checkpoints, and write headers before unwrapping keys or decrypting.
Signed chains, pins, and checkpoints
Signatures and hash chains bind principal policies and access manifests to their signers, predecessors, member identity commitments, and grant roots, while the organization policy commits every active group's current head. Clients persist full-bundle identity pins and monotonic checkpoints, rejecting key substitutions, forked histories, and rollbacks below observed state, and recording terminal verification failures in a local security-incident ledger.
Forward revocation and atomic rotation
Removing group members rotates the group key and every granted container's KEK in one atomic commit; removing a direct grant or moving a container rotates that container's KEK, and unlinking a document rotates its content key. Rotation leaves prior keys no forward bridge to post-rotation epochs (unless the user still holds a separate valid access path), while previously received keys, nested subtrees, and retained history follow the bounds under Trust boundaries.
Cryptography
Payload encryption, recipient key encapsulation, state authentication, commitments, and local at-rest storage use explicit, domain-separated primitives.
Asymmetric operations in the client and API keying protocol are post-quantum only: ML-KEM-1024 (NIST FIPS 203) for key encapsulation and ML-DSA-87 (NIST FIPS 204) for signatures, with no classical RSA, ECDH, X25519, or Ed25519 fallback. Transport TLS and deployment SSH keys sit outside this protocol scope.
Synced content and access plane
| Purpose | Mechanism | Role |
|---|---|---|
| Document and file records | AES-256-GCM + HKDF-SHA256 | Authenticated encryption with a domain-separated per-record key derived via HKDF, paired with a signed content-write header. |
| Key encapsulation and wrapping | ML-KEM-1024 + AES-256-GCM | Encapsulates principal keys to members and container KEKs to users, groups, and parent-derived KEK keypairs. Content keys and KEK keyrings wrap under container KEKs with context-bound AES-256-GCM additional authenticated data (AAD). |
| Digital signatures | ML-DSA-87 | Authenticates principal policy states, access events, content-write headers, and origin-bound sign-in challenges. |
| Commitments and fingerprints | SHA-256 + HKDF-SHA256 | Computes public-key fingerprints, canonical state and manifest hashes, Merkle roots, streamed ciphertext digests, and document content-key commitments. |
Local storage and recovery
| Purpose | Mechanism | Role |
|---|---|---|
| Local key separation | HKDF-SHA256 | Derives domain-separated keys for SQLite, the local file store, and saved identities from each scope's wrapped root key. |
| Local database | ChaCha20 (SQLite3MultipleCiphers) | Encrypts the local SQLite database file at rest. |
| Local file store | AES-256-GCM | Encrypts local OPFS files in authenticated chunks with namespace, storage key, and chunk index bound in AAD. |
| PIN lock | PBKDF2-SHA256 + AES-256-GCM | Outer-wraps the host-encrypted root-key envelope under a key derived from the optional local PIN. |
| Password-protected backups | PBKDF2-SHA256 + AES-256-GCM | Encrypts exported backup archives under a key derived from the backup password. |
| Recovery phrase | BIP39, 24 words | Encodes 256 bits of entropy from which an identity's ML-DSA-87 signing and ML-KEM-1024 encapsulation seeds are derived via HKDF-SHA256. |
Local storage and PIN protection
The client isolates local at-rest keys across three keyring scopes—SQLite, the local file store, and persisted identities—each backed by its own context-bound wrapped root key. Persistent SQLite and file chunks live in the browser's Origin Private File System (OPFS), the encrypted identity registry lives in localStorage, and the host wrapping key and keyring manifest live in IndexedDB (only the manifest store falls back tolocalStorage when IndexedDB is unavailable).
The web app persists a non-extractable Web Crypto CryptoKey in IndexedDB; the desktop and mobile shells store exported raw AES-256 key bytes in IndexedDB instead. Tearleads does not store this wrapping key in a hardware-backed OS keychain or secure enclave on any platform, so at-rest protection relies on browser, WebView, and OS profile isolation.
Configuring an optional PIN wraps the host-encrypted root-key envelope under a PBKDF2-SHA256 and AES-256-GCM key, requiring both the host wrapping key and the PIN to reopen the scope. On desktop and mobile shells (where the host key is stored as raw bytes), an attacker who obtains a copy of the app's storage—such as an unencrypted device backup—can test PINs offline, or decrypt the copy directly if no PIN was set; a copy of a browser profile's storage can permit the same. No PIN is set by default, and a local PIN does not alter remote access-plane authorization.
Service infrastructure
Production runs on Cloudflare Workers, Durable Objects, PlanetScale Postgres, and Cloudflare R2. Every server component sits on the untrusted service side of the confidentiality boundary in Fig. 2.
Trust boundaries
Residual risks, cold-start limits, and explicit non-goals of the protocol under the threat model above.
- First-contact identity anchoring
- Each device durably pins full user identity bundles by trust domain and user ID, rejecting any subsequent key change. Adding contacts, creating roster profiles, or enrolling new or disabled Members requires a direct anchor (this device's own keys or a verified identity link). Existing Members may receive group membership or container shares through signed Members history that commits their full identity bundle and chains back to such an anchor—an explicit transitive trust in every vouching administrator, including careless or malicious ones. First-sight signer observations never satisfy recipient admission. Deliver identity links over an authenticated channel; neither links nor chains prove global currentness.
- Cold-start rollback and split views
- Signatures and hash chains prove continuity, not global freshness. A device with no local checkpoint for an organization or container (a new device, a first-sight shared scope, or a reset local database) can be served older, internally valid signed history, and separate devices can be shown diverging views without cross-device witnessing or gossip. Within an observed organization, the signed organization policy commits every active group's current head, preventing isolated single-group rollback before a per-group checkpoint exists.
- Availability and withholding
- Denial of service sits outside the security boundary: a compromised service can withhold ciphertext, policy bundles, key wraps, or updates and refuse writes. When required verification evidence is absent, workflows fail closed rather than proceed with unverified state. An authorized writer can likewise submit undecryptable payloads or mismatched content-key wraps, causing availability failures (until repaired in a new epoch) without bypassing confidentiality or authorization.
- Endpoint and recovery-key compromise
- Local and end-to-end encryption do not defend against a compromised operating system, malicious code running in an unlocked client, or physical capture of displayed secrets. Anyone who obtains the 24-word recovery phrase—including its plaintext QR code—can deterministically derive that identity's signing and encapsulation private keys, and an unencrypted local backup file contains exported database rows and attachment bytes directly.
- History-inclusive container access
- Container access includes retained history by design: each current container KEK seals the container's predecessor keyring, allowing newly granted members to decrypt historical epochs. Compromising a current container KEK therefore exposes that container's retained history.
Revocation, nested containers, and historical authority
Revocation is forward-looking: it cannot erase keys or plaintext a former member already obtained while authorized. Rotating a parent container KEK rekeys intermediate descendants that sit above a directly shared container (within the carried-rekey cap), while unshared nested branches are not eagerly rekeyed until rotated directly or repaired along the path of a later write. Best-effort descendant re-citation (refreshing a held child folder's signed manifest citations to newer ancestor heads) narrows the stale-authorization window without rotating child KEKs or promising post-revocation confidentiality from a former member.
Without external currentness witnessing, a revoked signer colluding with a compromised server can present events or writes signed under valid historical authority to a device that has not yet observed a newer advancing event. Verifying a signature proves authority at the cited state head, not wall-clock creation time.
Documentation
Published directly from the public Tearleads repository, these guides, protocol specifications, bounded TLA+ models, operational limits, and API reference pages define the rules and residual boundaries in detail.
- Backup and restore
- Export a local backup, read its file format, and restore it on a device.docs/backup-and-restore.md
- How re-keying works
- Follow folder and document keys through sharing, revocation, and moves.docs/re-keying.md
- Attribution and Loro updates
- Follow encrypted Loro updates, version-vector spans, and signed headers to edit attribution and blame.docs/attribution-and-loro-updates.md
- Security guarantees
- What each property protects, the threat model, and the known gaps.docs/security-guarantees.md
- Keying design
- How content keys, container keys, and recipients fit together.docs/keying-design.md
- Protocol specification
- Messages, proofs, validation rules, and failure semantics.docs/protocol-specification.md
- Cipher suites
- The cryptographic primitives and where each one is used.docs/cipher-suites.md
- Protocol models (TLA+)
- Bounded models of protocol safety rules that complement, not replace, tests.formal/README.md
- Hard limits
- Every bound the protocol enforces, what enforces it, and what happens past it.docs/limits-hard.md
- Soft limits
- Bounds set by browsers, devices, and hosting services that the protocol does not enforce.docs/limits-soft.md
- Glossary
- Shared protocol terms used across the documentation.docs/glossary.md
- API reference
- Every HTTP operation, the fields it accepts and returns, and the rules the server enforces.docs/openapi.json