Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Always prompt if multiple MFA methods are running #47114

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

codingllama
Copy link
Contributor

@codingllama codingllama commented Oct 2, 2024

Fixes a scenario where the MFA prompt wouldn't show if the user has both OTP and WebAuthn devices, but no WebAuthn device is plugged.

I've moved the prompt for "dual prompt" scenarios (OTP+WebAuthn) outside of wancli and directly into lib/client/mfa. This prompts earlier, but is overall more resilient to some goroutine failing (which was the case here).

I also fixed a (theoretical?) deadlock on the "WebAuthn with PIN" scenario (otpDone is never closed in that branch). I can't quite make it happen with the devices I have today (MFA scenarios don't prompt for PIN and passkeys go to other branches), but that doesn't mean it couldn't happen with some other/future device.

#43072

Changelog: Fix missing tsh MFA prompt in certain OTP+WebAuthn scenarios

@codingllama
Copy link
Contributor Author

Backport to v14 is unlikely to happen, but I'll give it a shot when we get there.

@codingllama
Copy link
Contributor Author

Rebased and resolved conflicts. No noteworthy changes.

@codingllama
Copy link
Contributor Author

I've tested various combinations manually to make sure that it works and no other prompts are affected (they shouldn't be, but no harm in testing). I've also tested tsh on Windows.

Scenarios include:

  • OTP + WebAuthn login (both outcomes, no security key plugged) -> this is the bug scenario
  • OTP + WebAuthn login (both outcomes)
  • OTP only login
  • Webauthn only login
  • Passkey login

Plus the same matrix but on Windows.

type WebauthnLoginFunc func(ctx context.Context, origin string, assertion *wantypes.CredentialAssertion, prompt wancli.LoginPrompt, opts *wancli.LoginOpts) (*proto.MFAAuthenticateResponse, string, error)
// WebauthnLoginFunc is a function that performs WebAuthn login.
// Mimics the signature of [webauthncli.Login].
type WebauthnLoginFunc = libmfa.WebauthnLoginFunc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you actually want a type alias here or do you want a new type definition (like you had before).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The type alias is fine here, I think. I would rather have l/c/mfa.WebauthnLoginFunc everywhere, but I'm afraid the larger refactor would make backports more difficult.

@codingllama
Copy link
Contributor Author

Friendly ping @Joerger @marcoandredinis @probakowski ?

Copy link
Contributor

@marcoandredinis marcoandredinis left a comment

Choose a reason for hiding this comment

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

Changes look good
I've also tested this locally and it is now asking for the OTP on my use case as well.
Thank you for the quick fix

@codingllama codingllama added this pull request to the merge queue Oct 3, 2024
Merged via the queue into master with commit 85c6193 Oct 3, 2024
38 checks passed
@codingllama codingllama deleted the codingllama/otp-prompt branch October 3, 2024 19:21
@public-teleport-github-review-bot

@codingllama See the table below for backport results.

Branch Result
branch/v14 Failed
branch/v15 Failed
branch/v16 Failed

codingllama added a commit that referenced this pull request Oct 3, 2024
* fix: Always prompt if multiple MFA methods are running

* Fix deadlock on OTP+WebAuthn+PIN prompts

* Fix races on wanwin.PromptPlatformMessage
codingllama added a commit that referenced this pull request Oct 3, 2024
* fix: Always prompt if multiple MFA methods are running

* Fix deadlock on OTP+WebAuthn+PIN prompts

* Fix races on wanwin.PromptPlatformMessage
github-merge-queue bot pushed a commit that referenced this pull request Oct 4, 2024
* fix: Always prompt if multiple MFA methods are running

* Fix deadlock on OTP+WebAuthn+PIN prompts

* Fix races on wanwin.PromptPlatformMessage
github-merge-queue bot pushed a commit that referenced this pull request Oct 4, 2024
* fix: Always prompt if multiple MFA methods are running

* Fix deadlock on OTP+WebAuthn+PIN prompts

* Fix races on wanwin.PromptPlatformMessage
codingllama added a commit that referenced this pull request Oct 7, 2024
* fix: Always prompt if multiple MFA methods are running

* Fix deadlock on OTP+WebAuthn+PIN prompts

* Fix races on wanwin.PromptPlatformMessage
github-merge-queue bot pushed a commit that referenced this pull request Oct 7, 2024
* fix: Always prompt if multiple MFA methods are running

* Fix deadlock on OTP+WebAuthn+PIN prompts

* Fix races on wanwin.PromptPlatformMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants