Repository navigation
Conversation
The local ClientDb key now wraps into the same SecretEnvelope (agent-secret wrapper, XChaCha20-Poly1305) as drive vault keys. Legacy AES-GCM v1 records are read on sign-in and rewrapped as v2; they are kept for rollbacks and only written when the wasm bundle cannot load. Remove the unused recovery-code, password and webauthn-prf wrappers from the Rust SecretEnvelope. Envelopes carrying unknown wrapper kinds still parse and open through the kinds this build knows, and refuse to be rewritten.
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 37585749 | Triggered | Generic Password | 4f6fe33 | lib/src/vault/secret_envelope.rs | View secret |
| 37585749 | Triggered | Generic Password | 49ac330 | lib/src/vault/secret_envelope.rs | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
The GitGuardian "Generic Password" hit on Generated by Claude Code |
A v2 wrapped DbKey needs the wasm bundle, which ensureDbKeyOnSignIn now loads on the main thread before it reads any record. When a caller sets the agent before saving it (GettingStartedFlow does), the database opener finds the wrapped record without a session key and polled for only 3s; on a cold page the wasm load takes longer, so the opener gave up and the encrypted database stayed closed until the next sign-in. The v1 unwrap this replaced took milliseconds. saveAgentToIDB now announces the sign-in (trackDbKeySignIn) before its first await, and waitForSessionDbKey waits for an announced sign-in however long it takes, keeping the 3s poll only when none is in flight. vaultKeyOps also loads the versioned wasm pair like every other main-thread load, and no longer caches a failed load for the page's lifetime.
|
Traced the Where the log line comes from. "cannot be decrypted with this agent's key … Discarding" is Why the devDrive flow can't produce that.
Checked by running it, on a Vite production build with the service worker and What #1767 did break (fixed in 532cc3d).
Tests.
Generated by Claude Code |
… spec Dumps which keyval-store records exist (keys only; session keys as a 4-byte SHA-256 prefix), the agent subject, its fingerprint and whether a wrapped key record exists, right after devDrive and after the reload to the automation. Logged to the CI output and attached to the test result, so a failure on CI shows whether the key changed or the wrapped record was missing.
Requested by Joep · project thread
Before: the agent secret protected keys in two unrelated ways. The local database key (
localDbKey.ts) was AES-GCM under an HKDF key derived from the raw private key; drive vault keys (vaultWrapKey) were a RustSecretEnvelope(XChaCha20-Poly1305, KEK = BLAKE3 over the agent's vault proof). The Rust envelope also carried recovery-code, password and WebAuthn-PRF wrappers that no production path ever wrote.After: both keys use the same
SecretEnvelopewith an agent-secret wrapper. Existing local DB keys keep opening: the old record is read on sign-in and rewrapped into the new one. The Rust envelope only has the two wrappers that are used (agent-secret, node-key).How:
ensureDbKeyOnSignInnow gets the vault proof (already computed instoreSecret) alongside the private key, and loads the same wasmvaultWrapKey/vaultUnwrapKeythat the vault uses.SecretEnvelopelosesRecoveryCode,Password,WebauthnPrf,Unlock::Secret, the recovery-code generator and the Argon2 fields; a#[serde(other)] Unknownkind keeps old or foreign envelopes parseable.What was checked first
RecoveryCode/Password/WebauthnPrf/Unlock::Secret/generate_recovery_code: only referenced insecret_envelope.rstests. The wasm bindings only callcreate/unwrap_secretwithAgentSecret;db.rsonly usesNodeKey+Unlock::Kek. So no stored envelope in the wild was written with those kinds.recovery.tshas its own "v2" format (AES-GCM,wrapper_typerowsrecovery-code/webauthn-prf) that atomic-saas stores and parses. That format is untouched by this PR, as is the Argon2id wasm export it uses (argon2idDeriveKey, still invault/keys.rs).wrappers). Wire namesagent-secret/node-keyare unchanged and pinned by a test.Migration (local DB key, in IndexedDB)
atomic.clientdb.wrapped-key.<fp>atomic.clientdb.wrapped-key-v2.<fp>{version: 2, envelope}SecretEnvelope, written from now onOn sign-in: v2 present → unwrap. Else v1 present → unwrap with WebCrypto, set the session key first, then write v2 (after checking the new envelope opens to the same key). Else session key only (pre-feature) or nothing → wrap / generate into v2.
Failure modes
add_wrapper/remove_wrapperrefuse it. Writing it back would store the placeholder in place of the real kind.Tests
cargo test -p atomic_lib --features "db,db-sled,ws,iroh,config,rdf,discovery,ring" --lib -- vault:: db::test: 129 passed. That covers the 18secret_envelopetests and thedb.rsnode-key tests. New tests: wire names are unchanged, and an envelope that carries removed wrapper kinds (withkdf/salt) still opens and rejects the wrong proof.cargo clippywas also skipped for disk reasons.cargo check -p atomic-wasm --target wasm32-unknown-unknown: ok.browser/data-browser:vitest rungives 1306 passed; the only failure is the knownscripts/integration-mcp.test.mjs.tsc --noEmitis clean, andpnpm run -r lintis clean.localDbKey.persistence.test.tscases:signout-signin-data.spec.tsnow expects the v2 prefix. I did not run it here.recovery.ts,recovery-enrollment.test.ts) is unchanged and its tests pass.