Zero-Knowledge Credential Protection

When you connect Toolcog to external services—GitHub, Stripe, Google—your credentials are encrypted with keys derived from secrets only you possess. Toolcog cannot decrypt your credentials. Not “we promise not to.” Cannot. The cryptography makes it impossible.

The Safety Deposit Box Model

Think of a bank’s safety deposit box. The bank provides the vault (secure storage), but opening a box requires two keys: the bank’s master key and your personal key. Neither party can open the box alone.

Toolcog’s credential protection works similarly, but goes further. Your credentials are encrypted with keys derived from your session token. Without a valid token—which only you possess—the encrypted data is indecipherable noise.

The result: even if someone compromises Toolcog’s database, they get encrypted blobs they cannot open. Even Toolcog’s operators cannot decrypt your credentials without your active session.

Four-Tier Envelope Encryption

Toolcog implements envelope encryption across four cryptographic tiers. Each tier protects the next, creating a chain where your credentials can only be unlocked by presenting a valid authentication token.

Tier 1: Your Auth Token

When you sign in, Toolcog creates an encrypted token containing:

This token lives in your browser as an HTTP-only cookie. It’s encrypted with Toolcog’s server key, but that only proves authenticity—the secret inside is what matters.

The secret is random, generated fresh for each session. It’s never stored in any database. It exists only inside your encrypted token.

Tier 2: Key Encryption Key (KEK)

When you perform an operation that needs credentials, your auth secret is used to derive a Key Encryption Key using HKDF (a cryptographic key derivation function).

The KEK is never stored. It’s derived fresh on each request, lives only in memory during that request, and is discarded immediately after. Different session types (browser, API key, OAuth) derive different KEKs even from the same secret, providing cryptographic isolation.

Tier 3: Vault Data Encryption Key (DEK)

Each user has a vault with a single Data Encryption Key. This DEK encrypts all your credentials. The DEK itself is encrypted (“wrapped”) with your KEK before storage.

The wrapped DEK is stored in the database, but it’s useless without your KEK—which can only be derived from your auth secret—which only exists inside your encrypted token—which only you possess.

Tier 4: Your Credentials

Finally, your actual credentials (OAuth tokens, API keys) are encrypted with the vault DEK.

Each credential is encrypted with AES-256-GCM, which provides both confidentiality (encryption) and integrity (tampering detection).

The Complete Chain

TierWhatWhere
1Auth token (account ID + secret)Your browser cookie
2Key Encryption Key (KEK)Derived in memory, never stored
3Vault Data Encryption Key (DEK)Stored wrapped, unwrapped with KEK
4CredentialsStored encrypted, decrypted with DEK

Each tier protects the next. The chain only completes when you present a valid token.

The Decryption Path

When AI executes an API call that needs credentials, here’s what happens:

  1. Your token arrives — The HTTP-only cookie accompanies the request
  2. Token decrypted — Server key reveals your account ID and auth secret
  3. KEK derived — HKDF transforms your auth secret into the KEK
  4. DEK unwrapped — Your stored wrapped DEK is decrypted with the KEK
  5. Credential decrypted — The DEK decrypts your stored credential
  6. Credential applied — The plaintext credential is used for the API call
  7. Memory cleared — KEK, DEK, and plaintext credential are discarded

Credentials exist in plaintext only transiently, during the moment of execution, then immediately discarded. They’re never logged, never cached, never persisted unencrypted.

What This Means for Security

Database Compromise

If an attacker gains access to Toolcog’s database, they get:

Without valid auth tokens, the entire vault is cryptographically sealed.

Server Compromise

If an attacker gains access to Toolcog’s servers, including the server key used to decrypt tokens, they still can’t access credentials at rest. They would need to intercept a valid token during an active session—and even then, they could only access that one user’s vault, not everyone’s.

Operator Access

Toolcog’s operators cannot decrypt your credentials. There’s no admin backdoor, no master key, no “break glass” procedure. The cryptographic design makes it impossible, not just prohibited.

Session-Scoped Access

Each session (browser login, API key, MCP connection) has its own wrapped copy of your vault DEK. This enables:

When you sign out or revoke a session, that session’s ability to derive the KEK is destroyed. The vault DEK remains safely encrypted, accessible only through your other active sessions.

Important: If you sign out or let a session expire and no other session shares the vault, the vault becomes permanently inaccessible. This is intentional—credentials are easy to re-authorize. See Vault Linking to keep vault access across sessions.

Vault Linking

By default, each login creates its own vault. If you log in on your laptop and separately on your phone, each session has an independent vault with independent credentials. This provides isolation but means credentials don’t automatically synchronize.

Automatic Linking

When you create an API key or authorize an MCP client from an existing session, the new grant automatically shares your vault. The creating session wraps its vault DEK with a key the new grant can derive, and passes it through the authorization flow. No separate key exchange is needed—vault access is embedded in the authorization itself.

This is why connecting an MCP client from a logged-in browser gives the client access to your existing credentials. The browser session’s vault DEK flows to the new grant as part of the OAuth authorization.

Vault Merging

For sessions created independently (different browsers, different devices), X25519 key escrow enables after-the-fact unification.

Each grant has a persistent X25519 keypair. To merge vaults:

  1. The initiating session wraps its vault DEK using ECDH: initiator’s private key + recipient’s public key
  2. The wrapped DEK is stored as an escrow record
  3. The recipient derives the same shared secret: recipient’s private key + initiator’s public key
  4. The recipient unwraps the DEK and re-wraps it with their own KEK

Each escrow uses a fresh ECDH derivation, providing forward secrecy. Escrows expire after 24 hours.

Credential Migration

When you claim a vault escrow, credentials from your old vault are migrated:

  1. Each credential is decrypted with the old vault’s DEK
  2. Re-encrypted with the shared vault’s DEK
  3. Stored in the shared vault

If both vaults have the same credential (same service and scheme), the more recently created one is kept. Nothing is lost—your credentials consolidate into the shared vault.

Comparison with Traditional Storage

Traditional Approach

Most services store credentials in a database with application-level encryption:

Toolcog’s Approach

Technical Details

Algorithms Used

ComponentAlgorithmKey Size
Token encryptionAES-256-GCM256-bit
Key derivationHKDF-SHA-256256-bit
Key wrappingAES-KW (RFC 3394)256-bit
Credential encryptionAES-256-GCM256-bit
Key agreementX25519256-bit

Integrity Protection

Every layer includes integrity verification:

Any tampering at any layer causes immediate, obvious failure—not silent corruption.

Forward Secrecy

When sessions end:

Even if a future compromise exposed everything, past sessions’ credentials remain protected.

What You Need to Know

Your Responsibility

Toolcog’s Guarantees

Compliance Implications

This architecture supports compliance requirements that mandate:

Next Steps