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 crash when using Windows Hello in a Remote Desktop session #9006

Merged
merged 1 commit into from
Feb 15, 2023

Conversation

Gibstick
Copy link
Contributor

@Gibstick Gibstick commented Jan 19, 2023

Summary: This change fixes #7890 by catching a previously uncaught exception, and adds fallback behaviour when quick-unlock fails.

Windows Hello can suddenly become unavailable with a permission denied exception. According to #7890 (comment):

  1. Unlock a database with Windows Hello enabled
  2. Lock the database
  3. Connect to the machine in a remote desktop session
  4. Attempt to use Windows Hello to unlock the database by clicking the big button with the fingerprint icon

Note that this might not be the only way to trigger this. For example, one could disable Windows Hello and probably end up with the same crash.

So far I've been calling this "Windows Hello", but I'm not too familiar with the Windows APIs, so I'm not sure if KeyCredentialManager.RequestCreateAsync Method is technically Windows Hello. In any case, it comes up as a crash in the Windows Hello flow. It crashes because of an uncaught exception being returned, and it seems the error is by design because of extra restrictions Microsoft wanted to place on remote desktop sessions.

In the second commit, I made a quick attempt to improve the overall experience by falling back to the other unlock methods if quick unlock fails for any reason. This is a bigger change than just preventing the crash, so I'm open to feedback, including simply removing the second commit from this PR if it's contentious. This fallback behaviour I implemented was suggested in the original issue report and I think it's sensible.

Screenshots

image
Clicking "Unlock Database" in a remote desktop session used to crash, now it doesn't.

Testing strategy

I tested this by using the reproduction steps in the linked issue #7890, using a real RDP session. I first reliably reproduced the crash on an unmodified build, and then verified that my fix stopped the crashes.

Type of change

  • ✅ Bug fix (non-breaking change that fixes an issue)

@droidmonkey
Copy link
Member

Dang I didn't put enough in the try/catch block. BTW this behavior is undocumented in the winrt documentation.

@Gibstick
Copy link
Contributor Author

Yeah no worries, I couldn't find anything about it either.

I neglected to consider all platforms in buildDatabaseKey and I'll be pushing up a fix for that soon.

@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2023

Codecov Report

Base: 64.62% // Head: 64.41% // Decreases project coverage by -0.21% ⚠️

Coverage data is based on head (8d8fd04) compared to base (54ae46a).
Patch coverage: 0.00% of modified lines in pull request are covered.

❗ Current head 8d8fd04 differs from pull request most recent head d422f38. Consider uploading reports for the commit d422f38 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9006      +/-   ##
===========================================
- Coverage    64.62%   64.41%   -0.21%     
===========================================
  Files          342      341       -1     
  Lines        44334    44258      -76     
===========================================
- Hits         28649    28505     -144     
- Misses       15685    15753      +68     
Impacted Files Coverage Δ
src/gui/DatabaseOpenWidget.cpp 57.10% <0.00%> (-0.08%) ⬇️
src/sshagent/OpenSSHKey.cpp 79.01% <0.00%> (-2.18%) ⬇️
src/browser/BrowserService.cpp 27.10% <0.00%> (-1.81%) ⬇️
src/gui/styles/base/phantomcolor.h 70.00% <0.00%> (-1.43%) ⬇️
src/browser/BrowserAction.cpp 9.20% <0.00%> (-1.23%) ⬇️
src/core/FileWatcher.cpp 85.54% <0.00%> (-1.20%) ⬇️
src/gui/DatabaseTabWidget.cpp 61.21% <0.00%> (-0.62%) ⬇️
src/core/Database.cpp 83.77% <0.00%> (-0.57%) ⬇️
src/gui/tag/TagsEdit.cpp 59.32% <0.00%> (-0.13%) ⬇️
src/gui/MainWindow.cpp 71.49% <0.00%> (-0.08%) ⬇️
... and 76 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

src/gui/DatabaseOpenWidget.cpp Outdated Show resolved Hide resolved
@droidmonkey
Copy link
Member

You seem to have taken a very complex route to solve the problem cancel vs error problem. It would have been easier to either emit a "canceled()" signal or an error signal. In fact our current way of handling errors is incorrect and not thread safe. If another thread were to start a Windows Hello interaction then the error may get swallowed up.

@Gibstick
Copy link
Contributor Author

Good to know that signals exist, I'll redo it 😅

@deluxghost
Copy link

May I ask, what will happen after unlocking by fallback method in remote session? Do I still need to reopen keepassxc to re-enable fingerprint unlock in local session?

@droidmonkey
Copy link
Member

I figured out an elegant solution and also used the nice error messages that were going to waste!

The KeyCredentialManager::RequestCreateAsync call can fail because we can end up in a situation where Windows Hello is initially available but then becomes unavailable, such as during a remote desktop session. This commit prevents a crash by moving the call into the try-catch.

Fixes keepassxreboot#7890

Also resets quick unlock if there is an unrecoverable error. This will not occur if the user merely canceled the Windows Hello dialog.
@droidmonkey droidmonkey merged commit b84d38e into keepassxreboot:develop Feb 15, 2023
Perlover added a commit to Perlover/keepassxc that referenced this pull request May 18, 2023
Release 2.7.5

- Add menu option to allow screenshots [keepassxreboot#8841]
- Add support for Botan 3 [keepassxreboot#9388]
- Increase max TOTP step to 24 hours [keepassxreboot#9149]
- Improve HTML export layout [keepassxreboot#8987]
- Turn search reset off by default [keepassxreboot#9153]
- Use QClipboard::clear() instead of setting blank text [keepassxreboot#9148]
- Hide group column header choice when not in search [keepassxreboot#9171]
- Improve look of KeePassXC logo and icons [keepassxreboot#9355]
- Add keyboard shortcuts for app and database settings [keepassxreboot#9007]
- Hide rename button from attachments preview panel [keepassxreboot#8842]
- Linux: Set SingleMainWindow in .desktop file [keepassxreboot#7430]

- Fix crash when search clears while creating new entry [keepassxreboot#9230]
- Fix crash when using Windows Hello in a Remote Desktop session [keepassxreboot#9006]
- Fix crash in Group Edit after enabling Browser Integration [keepassxreboot#8778]
- Fix canceling quick unlock when it is unavailable [keepassxreboot#9034]
- Set password input field font correctly [keepassxreboot#8732]
- Greatly improve performance when rendering entry view [keepassxreboot#9398]
- Fix various accessibility issues [keepassxreboot#9138]
- Fix arrows size when expand/collapse a group [keepassxreboot#9096]
- Select the clone instead of the original after cloning an entry [keepassxreboot#9070]
- Fix bugs with preview widget [keepassxreboot#9170]
- Fix status bar update when switching to other DB [keepassxreboot#9073]
- Fix database settings spin box bug [keepassxreboot#9101]
- Fix Ctrl+Tab shortcut to cycle databases in unlock dialog [keepassxreboot#8839]
- Fix TOTP QR code maintaining square ratio [keepassxreboot#9027]
- Fix Auto-Type configuration page on custom sequence selection [keepassxreboot#8752]
- Fix unexpected behavior of `--lock` when KeePassXC is not running [keepassxreboot#8889]
- Make open folder icon exempt from "Apply group icon to entry" [keepassxreboot#9205]
- Allow setting default file open directory with env var [keepassxreboot#9192]
- SSH Agent: Fix support for AES-256/GCM openssh keys [keepassxreboot#8968]
- Browser: Fix Native Messaging script path with BSD OS's [keepassxreboot#8835]
- MacOS: Fix text selection for Auto-Type clear field [keepassxreboot#9066]
- MacOS: Don't rely on AppleInterfaceStyle for theme switching [keepassxreboot#8615]
- Windows: Remove registry detection of desktop shortcut [keepassxreboot#9380]
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.

Windows hello crash when on remote desktop
4 participants