Repository navigation
fix(passkey): store credential flags and read UV from the assertion - #179
Merged
Merged
Conversation
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 Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Passkey sign-in has two bugs, both because authsome never stored a credential's WebAuthn flags:
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.FinishLoginreturns carries the stored "user verified" bit, not the assertion's.cred.Flags.UserVerifiedwas therefore always false, andIssueSessiongated every passkey sign-in. Loomplane hit this as soon as its dependencies resolved go-webauthn to 0.18.2.What changes
flagscolumn (postgres SMALLINT, SQLite INTEGER, mongo field). Each sign-in saves what go-webauthn settled on.FlagsStoreinterface (UpdateCredentialFlags). All four built-in stores implement it. A customStorekeeps compiling and working: its sign-ins take the backup bits from their own assertion.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.Testing
go test ./...passes, andgolangci-lint run ./plugins/passkey/...is clean.TestDiscoverableLogin_TwoStepOn_CodeOnlyWithoutUserVerificationfails on v0.18 without this change and passes with it.mainbehaves.FlagsRoundTripconformance case covers NULL vs. zero, all eight bits and updates in place. It passes on Memory, SQLite, Postgres and Mongo (-tags integration, Mongo viaAUTHSOME_MONGO_URI).TestAccount_twoStepAndPasskeyspasses against this branch on go-webauthn 0.18.2. Without the change it fails with403 mfa_required.