Repository navigation
Description
Summary
Identities.verifyIdentity caches verified identities by signatures.id and, on a cache hit, returns isEqual(identity, cached) (src/identities/identities.js L118–L128 at 2ee8387):
const verifiedIdentity = await verifiedIdentitiesCache.get(signatures.id)
if (verifiedIdentity) {
return isEqual(identity, verifiedIdentity)
}This assumes that one signatures.id belongs to exactly one identity document. That is not true for providers whose identity carries a fresh proof per session while the key that signs the id stays the same. A second, equally valid identity for the same id is then refused without the provider ever being asked. Through IPFSAccessController.canAppend, every entry it signed is refused too:
Could not append entry: Key "<identity hash>" is not allowed to write to the log
Where it happens
We use @le-space/orbitdb-identity-provider-webauthn-did (type webauthn). How its identities are made:
- The OrbitDB signing key (secp256k1) is derived from the passkey's PRF output, so it is the same in every session. Signatures are deterministic (RFC 6979), so
signatures.idis the same in every session too. signatures.publicKeyis a WebAuthn assertion overpublicKey + signatures.id. It is made per session, so it differs (differentauthenticatorDatacounter, different ECDSA nonce on the authenticator).- So each session has a different identity document and hash, with the same
id, the samepublicKeyand the samesignatures.id. Each one verifies on its own.
The failing case was a restore: the blocks of a database written in an earlier session are put back into a new session and the heads are joined. Measured in a browser (Chromium, virtual authenticator, made-up data):
| check on the earlier session's identity | result |
|---|---|
same id, publicKey, signatures.id as the current identity |
yes |
| provider's binding check (WebAuthn proof: type, challenge, UP flag, P-256 signature) | passes |
verifyIdentity on a fresh Identities({ ipfs }) (empty cache) |
true |
verifyIdentity on the session's Identities (current identity cached) |
false |
The same situation arises whenever entries from an earlier session reach a peer that holds a newer identity for the same id, for example replication between two devices of one user.
Suggested fix
Either of these keeps the cache's purpose (not re-running provider verification) without assuming one document per id:
- Key the cache by the identity's hash (the document) instead of
signatures.id. - On a hit whose cached identity is not equal, fall through to
Provider.verifyIdentity(identity)instead of returningfalse.
Option 1 seems simplest. A cache hit then means "this exact document was verified", which is what the isEqual check is trying to say.
Happy to open a PR with a test, if that is welcome.
Activity
feat(backup): restore a backup into an empty browser (#77) (#259)
archived01: another session of the same passkey may still write — Orb…
Another session of the same passkey may still write: OrbitDB's identi…
Another session of the same passkey may still write: OrbitDB's identi…
chore(identity): the identity-cache workaround comes from the provide…
fix(deps): passkey identity provider 0.14.0 (GHSA-7j39-c465-x35x) (#87)
chore(deps): @orbitdb/core ^4.0.2 (#92)