Skip to content

fix(passkey): store credential flags and read UV from the assertion - #179

Merged
juicycleff merged 1 commit into
mainfrom
fix/passkey-credential-flags
Nov 15, 2026
Merged

juicycleff merged 1 commit into
mainfrom
fix/passkey-credential-flags

Conversation

@juicycleff

Copy link
Copy Markdown
Contributor

Passkey sign-in has two bugs, both because authsome never stored a credential's WebAuthn flags:

  • Synced passkeys can't sign in at all. iCloud Keychain, Google Password Manager and any other backup-eligible authenticator fail with Backup Eligible flag inconsistency detected during login validation. go-webauthn compares the assertion's backup-eligible bit with the stored credential's, and ours is always false. This happens today on v0.17.4.
  • Under go-webauthn v0.18 every passkey sign-in asks for a second factor. From v0.18 the credential FinishLogin returns carries the stored "user verified" bit, not the assertion's. cred.Flags.UserVerified was therefore always false, and IssueSession gated every passkey sign-in. Loomplane hit this as soon as its dependencies resolved go-webauthn to 0.18.2.

What changes

  • Registration stores the flag byte in a new nullable flags column (postgres SMALLINT, SQLite INTEGER, mongo field). Each sign-in saves what go-webauthn settled on.
  • Saving goes through a new optional FlagsStore interface (UpdateCredentialFlags). All four built-in stores implement it. A custom Store keeps compiling and working: its sign-ins take the backup bits from their own assertion.
  • A passkey stored before the column (flags NULL) borrows only the backup bits from the assertion signing in with it. It never borrows "user verified".
  • Login parses the assertion first (ParseCredentialRequestResponse + ValidateLogin / ValidateDiscoverableLogin), and the UV that skips the second factor comes from that assertion. This behaves the same on v0.17 and v0.18.
  • go-webauthn is bumped to v0.18.2. The CHANGELOG has a v1.12.1 entry covering the migration.

Testing

  • go test ./... passes, and golangci-lint run ./plugins/passkey/... is clean.
  • The existing TestDiscoverableLogin_TwoStepOn_CodeOnlyWithoutUserVerification fails on v0.18 without this change and passes with it.
  • New tests:
    • a synced passkey signs in twice;
    • a passkey stored without flags signs in and gets them filled in;
    • a stored UV bit doesn't excuse a later presence-only assertion.
  • The two synced tests fail with the inconsistency error when the stored flags are ignored, which is how main behaves.
  • The new FlagsRoundTrip conformance case covers NULL vs. zero, all eight bits and updates in place. It passes on Memory, SQLite, Postgres and Mongo (-tags integration, Mongo via AUTHSOME_MONGO_URI).
  • End to end: loomplane's TestAccount_twoStepAndPasskeys passes against this branch on go-webauthn 0.18.2. Without the change it fails with 403 mfa_required.

authsome never stored a passkey's WebAuthn flags. go-webauthn compares a
sign-in's backup-eligible bit with the stored credential's, so synced
passkeys (iCloud Keychain, Google Password Manager) failed with "Backup
Eligible flag inconsistency". From go-webauthn v0.18 the returned
credential also carries the stored "user verified" bit rather than the
assertion's, so every passkey sign-in was asked for a second factor.

Registration now stores the flags in a new nullable column and each
sign-in saves what go-webauthn settled on, through the optional
FlagsStore interface every built-in store implements. A passkey stored
before the column borrows the backup bits from its first assertion.
Whether a sign-in verified its user is read from that sign-in's own
assertion, on any go-webauthn version. go-webauthn is now v0.18.2.

Tested with the passkey unit tests, new synced and pre-flags sign-in
tests, and the store conformance suite on memory, SQLite, Postgres and
Mongo.
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

@juicycleff
juicycleff merged commit d014a31 into main Nov 15, 2026
22 checks passed
@juicycleff
juicycleff deleted the fix/passkey-credential-flags branch November 15, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant