Repository navigation
fix: require a sign-in before a login flow enrols a passkey on an existing user - #3627
Merged
Merged
Conversation
…sting user A flow definition that offers passkey_register after the identifier step let an identifier alone enrol a passkey on the named account: the identifier pins a user factor, a non-provisional enrollment needed nothing more, and the enrolled passkey then counted as the credential that completed the sign-in. The domain now refuses a non-provisional enrollment unless the attempt carries a verified credential (password, passkey or SSO) or is the internal attempt of a management-plane enrollment, at issue and again at verification. The new integration test drives the takeover through a customer-authored flow and pins the refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmUfUXLYYadoWmLHgo7
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
fforootd
marked this pull request as ready for review
December 3, 2026 17:06
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change requiring prior authentication to add passkeys to existing accounts.
No open issues 🎉
What changed in this PR
Prevents identifier-only login flows from adding passkeys to existing accounts by requiring prior authentication.
Changes:
- Checks authentication during registration challenge issuance and verification, preserving provisional and internal enrollment.
- Adds regression coverage and updates authenticated test fixtures.
- Documents the security fix in a server patch changeset.
| File | Description |
|---|---|
apps/api/internal/service/auth_attempt.go |
Clarifies enrollment requirements in comments only. |
apps/api/internal/service/auth_attempt_registration_test.go |
Adds password factors to authenticated enrollment fixtures. |
apps/api/internal/domain/auth_attempt.go |
Enforces prior authentication for existing-user enrollment. |
apps/api/internal/domain/auth_attempt_registration_test.go |
Tests rejected identifier-only attempts and allowed enrollment paths. |
apps/api/internal/api/integration_test/passkey_register_identifier_only_test.go |
Adds an end-to-end regression test for identifier-only enrollment. |
apps/api/internal/api/integration_test/helpers/passkey_registration.go |
Updates the enrollment helper to represent an authenticated user. |
.changeset/passkey-enrol-needs-sign-in.md |
Adds customer-facing release notes for the security fix. |
Review effort: Balanced
This branch was successfully deployed
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.
Context
Summary
This change prevents passkey enrollment on existing user accounts unless the user has first authenticated with a verified credential (password, passkey, or SSO). Previously, a login flow offering passkey registration immediately after the identifier step would allow anyone who knew an account's email address to add their own passkey and sign in as that user.
Key changes:
requireProvenUserForEnrollment()method toAuthAttemptthat enforces verified credential requirement for non-provisional passkey enrollmentPreparePasskeyRegistrationChallenge()to call this validation when a user factor is pinnedPreparePasskeyRegistrationVerification()to validate the requirement during verificationTestPasskeyRegisterAfterIdentifierOnlyIsRefuseddemonstrating the security fixBehavior:
400 att.invalid_requestValidation
TestPasskeyRegisterAfterIdentifierOnlyIsRefusedfailed: the identifier-only attempt enrolled the passkey and reacheddonewith a handoff token.go test ./internal/domain/ ./internal/flowengine/ ./internal/service/(inapps/api): pass.go test -tags sqlite_integration ./internal/api/integration_test/: the whole lane passes, including the passkey upsell, passkey-login-then-register and management-plane enrolment tests.go vet ./internal/domain/ ./internal/service/,go vet -tags sqlite_integration ./internal/api/integration_test/...and$(go env GOROOT)/bin/gofmt -l: clean.go test ./...: only the threecmd/servermux tests fail, with "console UI not embedded" (the console was not built in the container); unrelated.Release notes / changeset
Changeset:
.changeset/passkey-enrol-needs-sign-in.md— A login flow that offers passkey registration right after the identifier step no longer lets someone who knows an account's login name add their own passkey to it and sign in: adding a passkey to an existing user now takes a password, passkey or SSO sign-in first and is otherwise refused with400 att.invalid_request. (@zitadel/server)Notes
This is a security fix that closes a privilege escalation vulnerability. The change is backward compatible for legitimate flows (those requiring authentication before passkey enrollment) but will break flows that incorrectly offered passkey enrollment without prior authentication.
A static flow-definition validator rule was not added: purposes flip implicitly (e.g.
user_already_existson sign-up), so the domain check is the fail-closed floor.https://claude.ai/code/session_0137eGmUfUXLYYadoWmLHgo7
Generated by Claude Code