Skip to content

fix: require a sign-in before a login flow enrols a passkey on an existing user - #3627

Merged
fforootd merged 1 commit into
mainfrom
claude/compassionate-goldberg-3o2rmu
Dec 3, 2026
Merged

fforootd merged 1 commit into
mainfrom
claude/compassionate-goldberg-3o2rmu

Conversation

@fforootd

@fforootd fforootd commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Context

  • Closes security issue where passkey enrollment was allowed after identifier-only step

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:

  • Added requireProvenUserForEnrollment() method to AuthAttempt that enforces verified credential requirement for non-provisional passkey enrollment
  • Updated PreparePasskeyRegistrationChallenge() to call this validation when a user factor is pinned
  • Updated PreparePasskeyRegistrationVerification() to validate the requirement during verification
  • Added integration test TestPasskeyRegisterAfterIdentifierOnlyIsRefused demonstrating the security fix
  • Updated existing tests to reflect the new requirement (pinned user + password factor for valid enrollment)

Behavior:

  • Passkey enrollment on existing users now requires: user factor + verified credential (password/passkey/SSO) OR internal attempt
  • Identifier-only attempts (user factor without credential) are rejected with 400 att.invalid_request
  • Provisional enrollment (new user signup) remains unaffected
  • Internal attempts bypass the requirement (management API can enroll on behalf of user)

Validation

  • Before the fix, TestPasskeyRegisterAfterIdentifierOnlyIsRefused failed: the identifier-only attempt enrolled the passkey and reached done with a handoff token.
  • go test ./internal/domain/ ./internal/flowengine/ ./internal/service/ (in apps/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 three cmd/server mux tests fail, with "console UI not embedded" (the console was not built in the container); unrelated.
  • Not run: the Postgres and Spanner lanes (the change is domain logic, not storage).

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 with 400 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_exists on sign-up), so the domain check is the fail-closed floor.

https://claude.ai/code/session_0137eGmUfUXLYYadoWmLHgo7


Generated by Claude Code

…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
@vercel

vercel Bot commented Dec 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Dec 3, 2026 5:04pm UTC

Request Review

@fforootd fforootd changed the title Require sign-in before passkey enrollment on existing users fix: require a sign-in before a login flow enrols a passkey on an existing user Dec 3, 2026
@fforootd
fforootd marked this pull request as ready for review December 3, 2026 17:06
Copilot AI balanced review requested due to automatic review settings December 3, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@fforootd
fforootd added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit 296185c Dec 3, 2026
16 of 17 checks passed
@fforootd
fforootd deleted the claude/compassionate-goldberg-3o2rmu branch December 3, 2026 17:44

This branch was successfully deployed

1 active deployment
Preview — 5bbf19a5 Deployed Dec 3, 2026 by vercel[bot]
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.

3 participants