Tearleads

Security guarantees: identity and policy

Principal policy integrity, login challenges, signed timestamps, admin authorization, and revocation.

Part of security properties in the security guarantees.

Principal Policy Integrity

A principal signature binds its type/id, version and predecessor, key epoch and encapsulation key, membership/projection/envelope roots, encrypted payload hash, member count, signer identity, and timestamp. The server validates this before storage; API authorization consumers and clients revalidate complete chains before use. Projection rows are therefore not authority by themselves: changing them without a matching signed state causes rejection. Every principal-state write, including group creation and provisioning, re-verifies the stored chain from rows inside the storing transaction before commit.

Login Challenges Name The API

A login signature covers the challenge, the signing-key fingerprint, and the API’s canonical origin. The API checks it against its configured API_PUBLIC_ORIGIN, which production requires as a bare https origin. A challenge that a malicious API relays from the real one was therefore signed for the relay’s origin and never verifies. Outside production an unset origin falls back to each request’s own origin, which comes from its Host header and which a relay controls. The API warns about that fallback at startup.

Signed Timestamps

Every signed signedAt is canonical Date#toISOString() form with a year in 1970-9999, the only range a timestamp column serves back verbatim (0001-0099 hit the two-digit-year pivot; expanded years are rejected). Shared readers enforce this on both sides, and the API asserts inside the storing transaction that the written row prints the exact submitted string, so an irreproducible header never commits. Honest clients sign Date.now(), so no honest data is refused; a failing header is a malformed request, not an unauthorized signer.

Admin-Signer Authorization

Every signed principal-state header includes externalAuthority. It is null for a signer authorized directly by the initial or preceding projection. An externally authorized organization-group state instead commits the exact reserved Admins policy head. The API accepts only its current exact head and a direct admin signer; organization and Admins states cannot cite it.

Verification resolves every non-null citation to that exact Admins history entry and tests its projection, rather than unioning historical admins. Successors may cite historical heads after Admins advances. Citations cannot roll back within a chain; policies must descend from local checkpoints. Clients refuse only what an honest server cannot produce, so accepting honest history never depends on another device’s cache or write.

A removed admin with a compromised server can append using historical authority until a current admin’s successor cites newer authority, final for clients that observed that advance. The API requires current authority at commit; proving currentness needs witnessing or gossip.

The signed organization descriptor selects Admins; display and read-model projections never authorize policy or keying. Root and metadata repairs use verified grants.

Policy verification requires the current signed state contract.

Principal Payload And Projection Binding

The principal state’s projectionRoot commits each member’s user ID, role, and required identityBundleFingerprint, the complete identity-link bundle commitment. It must match the supplied projection; continuing members cannot change that bundle. membershipRoot remains an ID-set commitment. The state’s payloadCiphertextHash must match the supplied encrypted payload. The state’s memberCount must match the projection length. Its memberEnvelopesRoot must match the canonical exact envelope set. The signed grantRoot and grantCount likewise commit the complete canonical set of {containerId, accessLevel} grants for that principal. Current and historical policy bundle entries carry those grant projections, and both the client and API recompute the commitment before accepting them.

Grant commitments are part of signed state hashes. Local startup validates the required principal-policy columns before using cached policies.

Document and attachment events also sign their full authorization paths, deduplicated. Verification rebuilds paths by parent id from those citations, never from creation-time pins. Missing ancestors or two heads of one container are rejected. Runtime readers verify every signature, hash, and cited path.

Custom group names are encrypted inside their signed policy payloads with AES-256-GCM and a domain-separated key derived from the organization metadata container KEK. Authentication binds the group, organization, container and key epoch. All organization members can read every group’s name; the verified historical keyring preserves readability after rotation. The API has no group or organization name columns. Organization names live in encrypted profiles. The API refuses names citing other keys. A name that fails to decrypt is left blank and skipped for uniqueness, never failing the directory.

The organization metadata root has only Admins/admin and Members/read grants. Both signed group indexes bind its ID; creation also verifies its current projection and checkpoint. It never inherits personal-root shares or depends on personal-root rotations. Members rotations update its own KEK; historical names remain readable through its authenticated keyring.

Reserved Admins and Members labels are client constants. Their random group IDs and roles are authenticated by the signed organization descriptor; their roles and memberships remain visible to the service. They are not identified by server-provided display names.

Before displaying or acting on a name, clients verify the group’s signed directory binding and decrypt its metadata. Creation checks name uniqueness against that directory. Membership and grant successors retain the ciphertext; local decrypted display caches never enter API requests.

The app repeats these checks on fetched policy bundles. A bundle with a tampered projection, payload, state hash, chain link, signer, or checkpoint raises a typed terminal verification error. It is neither cached nor used for decryption, and the policy-warming or recovery workflow that received it aborts instead of reporting success.

Local Security-Incident Detection

The client records typed keying-verification failures from document sync, container reconciliation, managed-principal operations, and the trusted-user identity gateway before re-throwing the original terminal error. An exact error object is recorded only once even if it crosses several instrumented boundaries. A host callback or subscriber cannot replace the verification failure if it throws. Ordinary network and local-database availability failures remain retryable operational errors and are not labeled as tampering.

An incident proves that the received or stored material failed a local verification rule. It does not by itself prove that the server was malicious; corruption and implementation defects can produce the same signal.

Incident identities hash the evidence set in code-unit key order, so the same evidence yields one id on every device and locale and repeat observations merge; backup restore recomputes that identity and rejects non-canonical text.

Member Envelope Binding

The signed memberEnvelopesRoot commits each direct member’s identity, recipient fingerprint, KEM ciphertext, and wrapped key. The signed state binds the root and key epoch; verification checks the envelope bundle’s state hash and epoch. Principal signatures and hashes bind tearleads.principal-state. Exact ML-KEM-1024/AES-GCM formats are enforced. State, payload, projection, and envelopes commit atomically; the server cannot wrap without the principal key.

Revocation Depends On Principal Key Rotation

keyEpoch and the principal key fingerprint are signed and participate in object references to group policy state, so clients can detect mismatches between an object reference and the policy/key epoch used to decrypt it.

Validation records and checks key epochs, but membership removal only protects subsequent object envelopes when the principal key rotates. If a removed member previously learned the old principal secret key and a later state keeps the same principal key, that member can still decrypt later object envelopes addressed to that unchanged key. Strong post-removal confidentiality requires publishing a successor policy state with a fresh principal key epoch and fresh member envelopes for the remaining members.

The organization directory key differs: it encrypts no data. The organization payload is a plain signed descriptor, and container grants target only groups or users, so nothing is wrapped to an organization key but the admin envelopes of that same key. A directory write (group create, group policy commit, group delete) therefore keeps the key, epoch and envelopes while the Admins projection is unchanged, wraps it only for added admins, and rotates on any removal, which verifiers enforce (model). Reusing the key, or an admin rotating back to an old one, has no confidentiality consequence. A feature that encrypts to it must first restore rotation on every write or a no-reuse rule.

Managed Grants Fail Closed

Group container grants require an active signed group state. If a managed principal grant cannot be resolved to one, recipient resolution fails rather than degrading to unsigned expanded users, so unsigned group rows cannot create crypto recipients. Organization policies commit authority, not container grants.