Engineering postmortem

One passkey, two keys: what we learned about PRF, and the fix that protects every new wallet

Two keys derived from one passkey, with a check mark verifying that they match

TL;DR: WebAuthn PRF is a safe and deterministic way to derive a wallet key: the same passkey and the same salt always produce the same secret. We found one case where a password manager returned one value when the passkey was created and a different value at every login afterwards. Our mistake was to trust the create-time value without checking that a login reproduces it. The funds were recovered and are safe. The fix is a stability check at signup, a key comparison at every login, and one more check before any funds move. Other teams building on PRF can use the same three checks.

Author Emin Mahrt

6 minute read

This post is also available in Deutsch , Espaรฑol and Italiano .

What happened

A Nuri wallet key is derived on the user's device from the passkey's PRF output. It is never stored on our server. In one account, the passkey returned value A when it was created. A became the wallet key, and that key received funds.

Every login after that, the same passkey returned value B. B derives a different, empty wallet, so the app showed a zero balance. The funds had not moved. The app was simply deriving a wallet the funds did not belong to.

Two things had to go wrong for this to happen. The password manager returned two different answers for one passkey, and our app never compared them.

Why PRF is still the right tool

PRF is deterministic by design. CTAP2 hmac-secret stores a random secret for the credential, and the WebAuthn PRF output is computed from it with a fixed formula: HMAC-SHA256(CredRandom, SHA256("WebAuthn PRF" || 0x00 || salt)). Same credential, same salt, same output. That is exactly what makes it suitable as the root of a wallet.

Our derivation did not change at any point. The salt, the HKDF parameters and the BIP-32 path are identical today to what they were when the affected account was created, and the affected user's key still derives correctly from the original secret. The failure was not in PRF and not in our derivation. It was in which ceremony we took the value from, and in a check we did not run.

The two mistakes

Ours, and it is the important one: at signup we took the PRF output from the create() response and built the wallet on it. The WebAuthn spec allows that value to be absent, and it is not a verified promise about later logins. We then registered and funded the key without ever asking the passkey a second time, and at login we showed an empty wallet instead of reporting a key mismatch. Each of those is fixed now.

The password manager's: one credential returned one value at create and another at every get. We verified that the create value is exactly what the standard formula produces from the secret the manager stores. The login value matches no computation from that stored secret. Which component in the Android passkey chain causes this is still being investigated, and we will not name a culprit we cannot measure.

One honest limitation: our records prove that the registered key and the login keys differ. They do not prove whether the divergence existed on day one or appeared later. The checks below cover both.

How the funds were recovered

The recovery is the reassuring part of the story. The password manager keeps the secret that the PRF output is computed from. We decrypted the user's own backup offline, applied the standard PRF formula to that secret, and reproduced value A exactly. Running A through our normal derivation gave back the original wallet key.

We proved it before moving anything: a signature with the recovered key verifies, and rebuilding the deposit script from it reproduces the funded address exactly. The funds were then spent on-chain to the user's chosen destination and confirmed. No private key, PRF output or seed was published at any point, and none appears in this post.

The lesson for every user: the money was never at risk of being taken by anyone else, because every spend path requires the user's own key.

The fix

Three checks, all of them cheap.

1. Never derive a wallet from a create-time PRF. After create(), always read the PRF back with a get() on the new credential and use that value.

2. Compare before anything is registered or funded. If create and get disagree, stop, register nothing, and ask the user for a different password manager.

3. At every login, compare the derived key with the key stored for that credential. On a mismatch, show a clear error and open a support path. Never show an empty wallet, and never rebind automatically. Before any migration or deposit, re-derive and compare once more.

The signup comparison catches a provider that disagrees with itself immediately. The login and funding comparisons catch a provider whose answer changes later.

The core of the signup check is a few lines:

const created = await createWalletPasskeyCredential(rpId, prfSalt);

const assertion = await getAssertion({ rpId, challenge: randomBytes(32), credIdB64u: created.credIdB64u, prfSalt });

const prf = readPrfFirst(assertion);

if (!prf) throw new Error("missing_prf_after_create");

if (created.prfB64 && created.prfB64 !== toBase64(prf)) throw new Error("prf_unstable");

return { ...created, prfB64: toBase64(prf) };

Tests: a mock provider whose create answer differs from its get answer must make signup fail. A fixed PRF vector must always give the same key. A provider matrix must show create, get and get agreeing. On the server, a daily comparison of derived key against bound key turns silent drift into a support ticket instead of a surprise.

What we learned from filekey.app

filekey.app encrypts files with keys derived from passkey PRF, and it avoids the create-time trap entirely. Its enrollment only checks that PRF is supported, and the key always comes from a separate get() with a fixed salt and user verification required. Its code also documents why user verification matters: some authenticators keep a different secret per UV state.

Source: https://github.com/RockwellShah/filekey/blob/HEAD/reference/web/webauthn.ts

We adopted that model and added the explicit comparison on top, because a provider that disagrees with itself should be caught at signup, not after a deposit.

What other teams should take away

- Treat a create-time PRF as unverified. Build only on a value a get() has reproduced.

- Store the derived public key next to the credential id and compare it at every login.

- Fail closed. An error at signup costs one extra passkey prompt. A wrong key costs a recovery.

- Test the failure, not just the happy path: one mock provider that disagrees with itself is enough.

- Keep the derivation stable and versioned, so a recovered secret always rebuilds the same wallet.

What this means for Nuri users

Your keys are derived on your device and are not stored on our servers. The derivation itself is sound and unchanged. The affected funds were recovered, and the checks described here are now part of the app, so a mismatch is caught before a wallet is ever created, not after. No user action is needed.

If you ever see a balance that looks wrong, contact support instead of creating a new wallet. A key mismatch is exactly the case these checks now catch.

PRF is deterministic and safe when the value is verified. Three checks now make sure a mismatch is caught at signup, at login and before any funds move.

Emin Mahrt ยท Verification