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

Check passwords against the HIBP online service #4438

Merged
merged 16 commits into from
Mar 29, 2020

Conversation

wolframroesler
Copy link
Contributor

@wolframroesler wolframroesler commented Mar 14, 2020

Type of change

  • ✅ New feature (non-breaking change which adds functionality)

Description and Context

Add "HIBP" to the "Database -> Reports" panel to check all passwords in the database against the HIBP online service, and display the findings in a table. The "worst" passwords (found the most times in the HIBP database) are listed at the beginning of the table (just as in Health Check).

Offline checks (against a previously downloaded HIBP database file) will be added in another PR.

Lots of temporary commits, feel free to squash or fixup.

Fixes #1083 (together with the upcoming PR for offline checks).

Screenshots

Screenshot from 2020-03-14 12-54-55

Testing strategy

Tested manually.

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]

@wolframroesler wolframroesler changed the title WIP: Check passwords against the HIBP database Check passwords against the HIBP database Mar 14, 2020
@wolframroesler wolframroesler changed the title Check passwords against the HIBP database Check passwords against the HIBP web service Mar 14, 2020
@wolframroesler wolframroesler changed the title Check passwords against the HIBP web service Check passwords against the HIBP online service Mar 14, 2020
@droidmonkey
Copy link
Member

I squashed and rebased all the commits. Only 1 visual comment here:

  1. This dialog is way too wordy and steals focus. I would much prefer this to be in the actual HIBP report widget. For example, before permission is granted, a similar message to this is displayed instead of the results table with only one button "Perform Password Analysis". The technical details written in this dialog are irrelevant to the vast majority of users. Those should be hidden behind a "learn more" link that reveals them.
    image

Otherwise this performs REALLY REALLY well! I got great results from my personal database. The only issue I saw was my credit card entries where I put my CVC code in the password field. That is fine because it was obvious to me and entry templates will help with that problem in the future.

@droidmonkey
Copy link
Member

I am checking the code right now, and where it does work there are many efficiencies that can be had. Why do you jump from QString to StdString to C_Str? All operations can be smoothly done in QString. Additionally, you only use the HIBPDownloader once per password then reconstruct it, that is wasteful and the network manager can be loaded up with requests and it will do 5 at a time in batches. This will speed up lookups significantly.

src/core/HibpDownloader.cpp Outdated Show resolved Hide resolved
src/core/HibpDownloader.cpp Outdated Show resolved Hide resolved
src/gui/reports/ReportsDialog.cpp Outdated Show resolved Hide resolved
src/gui/reports/ReportsWidgetHibp.cpp Outdated Show resolved Hide resolved
src/gui/reports/ReportsWidgetHibp.cpp Outdated Show resolved Hide resolved
src/gui/reports/ReportsWidgetHibp.cpp Outdated Show resolved Hide resolved
@wolframroesler
Copy link
Contributor Author

Reworked as requested, please re-review.

One more thing. I tried to put the following at the beginning of HibpDownloader.hpp:

#ifndef WITH_XC_NETWORKING
#error This file requires KeePassXC to be built with network support.
#endif

to make sure it was included only when KeePassXC was built with network support. To my surprise, the #error fires all the time, even when building with cmake -DWITH_XC_ALL=ON. In the .cpp files, #ifdef WITH_XC_NETWORKING works as expected, but in the .h files, WITH_XC_NETWORKING never seems to be defined (same in ReportsWidgetHibp.cpp/.h). Any explanation for that?

@droidmonkey
Copy link
Member

droidmonkey commented Mar 21, 2020

You need to #include "config-keepassx.h" to use the predefines. We should probably be injecting those as defines in the build call instead of stuffing them in an include file. This is a carry over from KeePassX.

@droidmonkey
Copy link
Member

@wolframroesler for your awareness i have made significant code enhancements locally and will be pushing them soon. I optimized as much as I could and standardized to Qt and code base.

@droidmonkey
Copy link
Member

Pushed my code changes, here are some screenshots:

image

image


private:
void makeHibpTable();
void startValidation();
QString countToText(int count);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason why this is a non-static, non-const member function?

@wolframroesler
Copy link
Contributor Author

@droidmonkey Thanks for the rework, learned a lot from it :) I should have guessed that something like toHex exists in an all-bells-and-whistles-included library like Qt.

I particularly like the reworked warning message that appears when you switch to the HIBP pane, it's much better than my modal dialog. It looks like it's made to add a second button, "Perform Offline Analysis", after which you select your downloaded HIBP file in case you don't want to go online. Will implement that on a new branch after this one has been merged.

About the warning message, it says

your database passwords will be cryptographically hashed and the first five characters sent securely to this service

Will everyone understand that this is referring to the first five characters of the hash and not of the password?

@droidmonkey
Copy link
Member

Great point!

@wolframroesler
Copy link
Contributor Author

Fixed two details: fetchFailed had a wrong signature (produced a message on stdout), and it failed to build without networking support.

@droidmonkey
Copy link
Member

I did actually intend to remove the password QString from fetchFailed since it is unused and doesn't really matter. I completed my original change in the last commit and fixed the caution message. This should be good to go.

@droidmonkey droidmonkey merged commit 83ed9a8 into keepassxreboot:develop Mar 29, 2020
@droidmonkey
Copy link
Member

Claim your bounty good sir!

@wolframroesler
Copy link
Contributor Author

Thanks @droidmonkey :) will claim the bounty when offline checks are done too.

@droidmonkey
Copy link
Member

droidmonkey commented Mar 29, 2020

Don't wait for that, I think there are some time restrictions on this bounty. I can't recall if I added a 3 month limit or not.

@wolframroesler
Copy link
Contributor Author

https://www.bountysource.com/issues/50410294-check-passwords-against-hacked-password-databases says "You will be able to claim this bounty as soon as the original issue is marked as closed" so I suppose #1083 needs to be closed first.

@droidmonkey
Copy link
Member

It is closed 😬

@danielporto
Copy link

I'm so looking forward for this! Thanks a lot!!

droidmonkey added a commit that referenced this pull request Jul 7, 2020
Added

- Custom Light and Dark themes [#4110, #4769, #4791, #4796, #4892, #4915]
- Compact mode to use classic Group and Entry line height [#4910]
- View menu to quickly switch themes, compact mode, and toggle UI elements [#4910]
- Search for groups and scope search to matched groups [#4705]
- Save Database Backup feature [#4550]
- Sort entries by "natural order" and move lines up/down [#4357]
- Option to launch KeePassXC on system startup/login [#4675]
- Caps Lock warning on password input fields [#3646]
- Add "Size" column to entry view [#4588]
- Browser-like tab experience using Ctrl+[Num] (Alt+[Num] on Linux) [#4063, #4305]
- Password Generator: Define additional characters to choose from [#3876]
- Reports: Database password health check (offline) [#3993]
- Reports: HIBP online service to check for breached passwords [#4438]
- Auto-Type: DateTime placeholders [#4409]
- Browser: Show group name in results sent to browser extension [#4111]
- Browser: Ability to define a custom browser location (macOS and Linux only) [#4148]
- Browser: Ability to change root group UUID and inline edit connection ID [#4315, #4591]
- CLI: `db-info` command [#4231]
- CLI: Use wl-clipboard if xclip is not available (Linux) [#4323]
- CLI: Incorporate xclip into snap builds [#4697]
- SSH Agent: Key file path env substitution, SSH_AUTH_SOCK override, and connection test [#3769, #3801, #4545]
- SSH Agent: Context menu actions to add/remove keys [#4290]

Changed

- Complete replacement of default database icons [#4699]
- Complete replacement of application icons [#4066, #4161, #4203, #4411]
- Complete rewrite of documentation and manpages using Asciidoctor [#4937]
- Complete refactor of config files; separate between local and roaming [#4665]
- Complete refactor of browser integration and proxy code [#4680]
- Complete refactor of hardware key integration (YubiKey and OnlyKey) [#4584, #4843]
- Significantly improve performance when saving and opening databases [#4309, #4833]
- Remove read-only detection for database files [#4508]
- Overhaul of password fields and password generator [#4367]
- Replace instances of "Master Key" with "Database Credentials" [#4929]
- Change settings checkboxes to positive phrasing for consistency [#4715]
- Improve UX of using entry actions (focus fix) [#3893]
- Set expiration time to Now when enabling entry expiration [#4406]
- Always show "New Entry" in context menu [#4617]
- Issue warning before adding large attachments [#4651]
- Improve importing OPVault [#4630]
- Improve AutoOpen capability [#3901, #4752]
- Check for updates every 7 days even while still running [#4752]
- Improve Windows installer UI/UX [#4675]
- Improve config file handling of portable distribution [#4131, #4752]
- macOS: Hide dock icon when application is hidden to tray [#4782]
- Browser: Use unlock dialog to improve UX of opening a locked database [#3698]
- Browser: Improve database and entry settings experience [#4392, #4591]
- Browser: Improve confirm access dialog [#2143, #4660]
- KeeShare: Improve monitoring file changes of shares [#4720]
- CLI: Rename `create` command to `db-create` [#4231]
- CLI: Cleanup `db-create` options (`--set-key-file` and `--set-password`) [#4313]
- CLI: Use stderr for help text and password prompts [#4086, #4623]
- FdoSecrets: Display existing secret service process [#4128]

Fixed

- Fix changing focus around the main window using tab key [#4641]
- Fix search field clearing while still using the application [#4368]
- Improve search help widget displaying on macOS and Linux [#4236]
- Return keyboard focus after editing an entry [#4287]
- Reset database path after failed "Save As" [#4526]
- Use SHA256 Digest for Windows code signing [#4129]
- Improve handling of ccache when building [#4104, #4335]
- macOS: Properly re-hide application window after browser integration and Auto-Type usage [#4909]
- Auto-Type: Fix crash when performing on new entry [#4132]
- Browser: Send legacy HTTP settings to recycle bin [#4589]
- Browser: Fix merging browser keys [#4685]
- CLI: Fix encoding when exporting database [#3921]
- SSH Agent: Improve reliability and underlying code [#3833, #4256, #4549, #4595]
- FdoSecrets: Fix crash when editing settings before service is enabled [#4332]
@phoerious phoerious added pr: new feature Pull request that adds a new feature and removed new feature labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: Reports pr: new feature Pull request that adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check passwords against hacked password databases [$300]
4 participants