Skip to content

fix: preserve user_handle when adding a second WebAuthn security key#4543

Open
Micaso wants to merge 1 commit intoory:masterfrom
Micaso:fix/webauthn-user-handle-stability
Open

fix: preserve user_handle when adding a second WebAuthn security key#4543
Micaso wants to merge 1 commit intoory:masterfrom
Micaso:fix/webauthn-user-handle-stability

Conversation

@Micaso
Copy link

@Micaso Micaso commented Mar 4, 2026

The WebAuthn specification requires that user.id (user_handle) remains stable for the lifetime of an identity. The settings flow was unconditionally overwriting user_handle with the session identity ID each time a new WebAuthn credential was added, causing previously registered authenticators to fail during login because the stored handle no longer matched.

Only set UserHandle when it is not yet present (first credential added via settings). Existing credentials keep their original handle.

Closes #4519

Related issue(s)

#4519

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got the approval (please contact
    security@ory.com) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

The WebAuthn specification requires that user.id (user_handle) remains
stable for the lifetime of an identity. The settings flow was
unconditionally overwriting user_handle with the session identity ID
each time a new WebAuthn credential was added, causing previously
registered authenticators to fail during login because the stored
handle no longer matched.

Only set UserHandle when it is not yet present (first credential added
via settings). Existing credentials keep their original handle.

Closes ory#4519
@Micaso Micaso requested review from a team and aeneasr as code owners March 4, 2026 14:42
@Micaso Micaso changed the title fix(webauthn): preserve user_handle when adding a second security key fix: preserve user_handle when adding a second WebAuthn security key Mar 4, 2026
@Micaso
Copy link
Author

Micaso commented Mar 4, 2026

The two failing CI checks are pre-existing issues unrelated to this fix:

  • golangci-lint: Fails with the Go language version (go1.25) used to build golangci-lint is lower than the targeted Go version (1.26). The CI pins golangci-lint v2.4.0 (built with Go 1.25) but go.mod requires Go 1.26. This fails on any PR right now.

  • Anchore Scanner: Fails with high-severity CVEs found in the base Docker image oryd/kratos:a52cd61. These are image/dependency vulnerabilities, not introduced by this change.

Both failures are visible on the master branch as well. The actual code change and its regression test pass cleanly.

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.

Bug: WebAuthn user_handle is overwritten during Settings flow, breaking existing credentials

1 participant