257 Commits
Author SHA1 Message Date
Sami Vänttinen 300f0801a8 Passkeys: Fix use-after-free with passkey register/auth dialogs (#14011)
* Passkeys: Fix use-after-free with passkey register/auth dialogs
* Add one GUI test for testing the dialog rejection
2026-11-12 23:51:58 +01:00
Janek Bevendorff c263a116d9 Fix window geometry restoration bug
Sometimes KeePassXC did not restore the window geometry properly. This change moves the geometry restoration to before showing the window. That should fix issues especially when the window is moved to another monitor on Wayland, but it may also resolve other strange quirks that can happen when the window starts in the tray.
2026-11-02 18:00:31 +01:00
Jonathan White b5523be1a1 Additional fixes for macOS and modern Qt6
* Replace Q_OS_MAC with Q_OS_MACOS
* Remove deleted macro QTEST_DISABLE_KEYPAD_NAVIGATION
2026-10-15 14:18:47 -04:00
AetfandClaude Fable 5 8e6fe3ffd6 FdoSecrets: keep AccessControlDialog safe across database lock
The item access confirmation dialog used to hold raw Entry pointers in
its model, its deny buttons, and its result signal. When the database
locks or closes while the dialog is open, DatabaseWidget replaces the
Database and destroys every Entry, while the dialog stays up: painting
the model, or answering the dialog, then dereferenced freed entries
(crash in UnlockPrompt::itemUnlockFinished via Entry::uuid, see the
backtrace in #9104).

Make the dialog self-contained: snapshot each entry's uuid and display
data (title, username, icon) at construction and report decisions as a
QHash<QUuid, AuthDecision>, so the dialog never touches an Entry again
after it is shown.

On the UnlockPrompt side, restore the invariant that a non-null item
reference implies a usable backend: track items with QPointer and clear
all references as soon as an item retires (Item::itemAboutToDelete),
mirroring how collection retirement is handled. A decision for an item
that has retired counts as rejected, so the prompt completes as
dismissed instead of reporting success for nothing.

Finally, match the browser behavior: the dialog now withdraws itself
(rejects) when a collection it is asking about locks or goes away,
instead of keeping a stale question on screen.

Fixes #9104

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqHu6RpvLpaoH2aUGSYQzR
2026-09-14 19:44:08 -04:00
AetfandClaude Fable 5 30e1fa5dfb Fix use-after-free when a database tab close is re-entered (#13598)
* Fix use-after-free when a database tab close is re-entered

Closing a database tab may spin a nested event loop while the widget
performs save-on-close (Database::save waits for its worker thread in
AsyncTask::waitForFuture). If DatabaseTabWidget::closeDatabaseTab is
re-entered for the same widget from within that nested loop (e.g. two
concurrent FdoSecrets prompts deleting the same collection),
QWidget::close() short-circuits on its internal is_closing flag and
reports success immediately, without delivering another close event.
This behavior is identical in Qt 5 (QWidgetPrivate::close_helper) and
Qt 6 (QWidgetPrivate::handleClose), so none of the downstream guards
(such as DatabaseWidget::lock's m_attemptingLock) ever run for the
re-entrant close. The re-entrant call then removed the tab and
scheduled deletion, and the DeferredDelete event executed inside the
still-running nested loop, destroying the widget while the outer
invocation was still using it; the outer call afterwards repeated
parts of the teardown (stale-index removeTab, deleteLater on the freed
widget, duplicate databaseClosed emission). The bug is long-standing
and was surfaced by scheduler timing under an ASan build with Qt 6.11.

Detected by ASan as a heap-use-after-free in DatabaseWidget::save()
during TestGuiFdoSecrets::testCollectionDeleteConcurrent.

- DatabaseTabWidget::closeDatabaseTab: track widgets with a close in
  progress; a re-entrant call returns false without side effects, and
  only the outermost invocation may remove the tab, schedule deletion,
  and emit databaseClosed (exactly once now). Re-resolve the tab index
  after close() since nested event loops may shift tabs.
- FdoSecrets: PromptBase::prompt now schedules promptSync only once;
  repeated Prompt() calls wait for the same Completed signal instead
  of running the prompt action multiple times.
- FdoSecrets: DeleteCollectionPrompt clears its collection reference on
  Collection::collectionAboutToDelete. The QPointer alone still sees a
  retired collection (removed from D-Bus, m_backend already reset)
  until its deleteLater is delivered, which would violate the
  invariant behind Q_ASSERT(m_backend) in Collection::doDelete. With
  the explicit clearing the invariant "non-null m_collection implies
  usable backend" holds again and the assert stays.
- TestGuiFdoSecrets::testCollectionDeleteConcurrent: fix the second
  prompt proxy accidentally created from the first prompt's path (the
  test was exercising a double-Prompt on one object rather than two
  concurrent prompts), and assert the fail-fast behavior: the losing
  concurrent prompt completes as dismissed while the winner performs
  the deletion.

* FdoSecrets: complete prompts whose collections retire mid-prompt

A Collection retires (removed from D-Bus, backend reset, deleteLater
scheduled) synchronously when its database closes. Prompts, however,
reference collections via QPointer from timer callbacks outside D-Bus
dispatch, and a QPointer still sees the retired object until its
deferred deletion is delivered. This left two holes, both reachable
when a collection goes away while a prompt targeting it is in flight
(e.g. a concurrent Collection.Delete from another client):

- LockCollectionsPrompt/UnlockPrompt could call doLock()/doUnlock() on
  a retired collection, hitting Q_ASSERT(m_backend) in debug builds.
- UnlockPrompt would hang forever: the retired collection never emits
  doneUnlockCollection (its service connections are severed on
  retirement), and the count-based completion condition could no
  longer be satisfied, so the Completed signal never fired and the
  client waited indefinitely. The same accounting also hung when an
  entry was already destroyed by the time promptSync ran.

Following the same principle as DeleteCollectionPrompt: restore the
invariant that a non-null collection reference is usable, instead of
relaxing the asserts.

- LockCollectionsPrompt clears retired collection references on
  collectionAboutToDelete; a retired collection is skipped exactly
  like a destroyed one.
- UnlockPrompt tracks awaited collections in an explicit pending set,
  pre-registered before issuing any doUnlock so that synchronous
  completions (already-unlocked databases) cannot prematurely trigger
  the item unlock step. Retirement is accounted as a rejection and
  re-evaluates completion, so the prompt always terminates.
- Add regression test testServiceUnlockConcurrentDelete covering the
  unlock/delete race; verified to fail (hang detected via signal spy
  timeout) without this fix.

* FdoSecrets: clean up unlock dialog bookkeeping when the widget dies

Service::m_unlockingDb tracks databases with an unlock dialog shown to
prevent duplicate dialogs. If the DatabaseWidget is destroyed while
its dialog is open (e.g. the database is deleted via a concurrent
D-Bus call), dialogFinished never fires for it and the entry stayed
forever, keyed by a dangling pointer. The pointer was only ever
compared, not dereferenced, but the stale entry permanently blocked
doUnlockAnyDatabaseInDialog (used by unlock-before-search), and a
future widget allocated at the same address would have been refused an
unlock dialog as well.

Track a cleanup connection on the widget's destroyed signal alongside
the existing databaseUnlocked oneshot, covering both the per-database
and the unlock-any-database flows. Extend the
testServiceUnlockConcurrentDelete regression test to reopen the
database after the concurrent delete and verify the unlock dialog
still appears; without the fix the test times out in SearchItems
waiting for a dialog that never shows.

---------

Co-authored-by: Claude Fable 5 <[email protected]>
2026-08-23 22:45:29 -04:00
luo jiyin 003e7af49c Fix multiple spelling typos across codebase (#13424)
* fix(changelog,appdata,test): correct typos (ambigious→ambiguous, verticle→vertical, Localtion→Location, Bottons→Buttons, rectange→rectangle)

* fix(dbus,nixutils,keeshare,cr-recovery): correct typos (definiton→definition, executeable→executable, Certicate→Certificate, padd→pad)
2026-06-28 23:54:42 -04:00
Jess Sullivan b9bcbfc592 Fix: address #12631 2026-05-27 15:58:15 -04:00
Sami Vänttinen 7c7ca4575e WIP: Qt6 transition (#11651)
Update KeePassXC to use Qt 6.
2026-05-04 15:16:51 +03:00
Jonathan Whiteandvarjolintu aa0cac5c03 Refactor: move to simple default builds (#11003)
* Remove individual feature flags in favor of a single `KPXC_MINIMAL` flag that removes advanced features from the build. Basic features are no longer guarded by feature flags.
* Basic features: Auto-Type, Yubikey, KeeShare
* Advanced features include: Browser (and passkeys), SSH Agent, and Secret Service
* Networking, Documentation, and Update Checking remain as feature flags to accommodate various distro requirements.

This change also cleans up the main CMakeLists.txt by re-arranging some content and placing macros into a dedicated include file. The minimum CMake version was bumped to 3.16.0 to conform to our minimum Ubuntu support of Focal (20.04). This also allows us to default to C++20, we fall back to C++17 for Qt versions less than 5.15.0 due to lack of support.

Lastly this change removes the KEEPASSXC_BUILD_TYPE="PreRelease" which is never used. We only support "Snapshot" and "Release" now.

Additional cleanup of CMakeLists:

1. Removed always-true CMake version guard  if(CMAKE_VERSION >= 3.14.0)

2. Removed dead GCC 4.8 stack protector fallback; C++20 requires GCC 10+, and -fstack-protector-strong has been available since GCC 4.9.

3. Removed dead ASan LSan version guard for the same reason.

4. Converted set_target_properties( COMPILE_DEFINITIONS) to target_compile_definitions() on both keepassxc_core and keepassxc_gui. Both are now PRIVATE since the symbol is an internal build detail.

5. Scoped Qt5Gui_PRIVATE_INCLUDE_DIRS to keepassxc_gui preventing Qt-internal headers from leaking into every target in the build.

6. Use cmake_parse_arguments to cleanup test case definition macros. Remove test output formats as they are never used and can be controlled when tests are run.

* moved /fsanitize=address to compile options instead of definitions for MSVC builds

---------

Co-authored-by: varjolintu <[email protected]>
2026-04-18 22:37:30 -04:00
Jonathan White ad4a807e70 Fix the TOTP Gui test for Ubuntu Jammy
* For some reason the C locale setting is not respected in Jammy and the test fails due to attribute sorting
2026-04-13 06:04:12 -04:00
Janek BevendorffandJonathan White ada379fddd Fix Linux test failures (#13113)
* Fix test failure introduced by ab31a748fa (#10993)

* Fix tray hiding test failure

Introduced by 43904d87b7 (#10928), but somehow hasn't posed an issue until now.

* Try to make attachment GUI test more robust

---------

Co-authored-by: Jonathan White <[email protected]>
2026-03-06 17:59:02 -05:00
Tamino BauknechtandJonathan White c0ea6f65f9 Database merge confirmation dialog (#10173)
* Add Entry::calculateDifference()

This new function contains the logic that was previously in
EntryHistoryModel::calculateHistoryModifications().
It allows the re-use to display the differences in case of a merge.

* Introduce Database Merge Confirmation Dialog

Adds a dialog allowing a user to review the changes of a merge operation.
This dialog displays the changes and allows the user to abort the merge
without modifying the database.

Fixes #1152

* Added dry run option to Merger
* Changed behavior when actual merge differs from dry run to just output a warning to console
* Fixed KeeShare conflicting with merge operations in the middle of a merge

---------

Co-authored-by: Jonathan White <[email protected]>
2025-09-14 12:02:22 -04:00
CopilotandJonathan White dd023ca157 Fix pre-release issues with attachment viewer (#12244)
* Fix translation issues for "FIT" and "New Attachment" in attachment editor

* Fix markdown preview persistence and enable external links in attachment editor

* Update preview panel if manually moved from collapsed position

* Match edit view scroll position (by percentage) when changed. This ensures the preview remains in relative sync with the edited document, for example when a large amount of HTML reduces down to a short preview document.

* Fix default preview size to be half the width of the edit widget.

* Set tab stop to 10 and remove base ui file

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Jonathan White <[email protected]>
2025-09-08 06:22:20 -04:00
Jessy LANGEandJonathan White 7ec0f1f5a8 Add "press enter to search" option (#12263)
* Also increase auto-search timeout to 500 ms to improve user experience, especially with large databases. The previous value of 100ms guaranteed a search was performed after every character entered, even when typing relatively fast. 

---------

Co-authored-by: Jonathan White <[email protected]>
2025-07-06 14:16:25 -04:00
Jonathan White 76b2f377df Enforce new-line at end of code files 2025-07-06 11:50:24 -04:00
Kuznetsov Oleg f2a4cc7e66 Refactor attachment handling system with enhanced UI (#12085)
* Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity.
* Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments.
* Added functionality to preview attachments while editing them.
* Enhanced EntryAttachmentsModel with rowByKey method for better key management.
* Add image attachment support with zoom functionality.
* Add html and markdown detection.
* Improve button layout on the attachment section when editing an entry
2025-06-19 13:27:23 -04:00
Jonathan White 37ddbb3cd2 Remove Config::createTempFileInstance 2025-03-30 08:14:12 -04:00
Jonathan White 244ed42231 Improve remote sync tests 2025-02-23 22:18:47 -05:00
An-anonymous-coder 86f74a00d0 Removed newline and words with hyphen (#11409)
The newline at the end of the file was removed, as well as 4 words that contain a hyphen:
drop-in
felt-tip
t-shirt
yo-yo
2025-02-23 09:46:25 -05:00
Jonathan White edab0faa94 Add Proton Pass importer
* Closes #10465
2025-01-03 17:45:50 -05:00
e76e9d42c7 Passphrase "MIXED case" Type (#11255)
* An additional approach to create passphrases with one random word being in UPPERCASE.
* Also remove duplicate character count from passphrase generator

---------

Co-authored-by: Stephan Heffner <[email protected]>
Co-authored-by: Jonathan White <[email protected]>
2024-12-25 22:56:02 -05:00
Jonathan White 2738a72b43 Fix assert hit when viewing entry history
* Fixes #11371
* Adds test for showing entry history
* Improved page switching capabilities for entry edit widget
2024-10-27 06:49:10 -04:00
Jonathan White e07eb2c82c Overhaul action states and add icons to toolbar
* Fixes #10981
2024-10-06 23:22:18 -04:00
sforstandJonathan White d2da13da20 Support opening remote databases (#10896)
* Use the import wizard to support opening a remote database

---------

Co-authored-by: Jonathan White <[email protected]>
2024-10-06 22:39:50 -04:00
Janek Bevendorff e48ef80e9c Fix code formatting with new clang-format version 2024-07-28 18:25:12 -04:00
Jookia 0a516d526c tests: gui: Fix NULL dereference in GUI tests 2024-06-27 20:38:13 -04:00
Sami VänttinenandJonathan White fbdd97b1be Refactor Database Settings (#9485)
Includes following changes:

* Encryption Settings now has a similar key with the new database wizard for switching between Advanced and Simple Settings
* The extra UI layer DatabaseSettingsDialog.ui has been removed. DatabaseSettingsDialog class now inherits EditWidget instead of DialogyWidget (just like Application Settings).
* Extra classes for separate page settings (DatabaseSettingsPageFdoSecrets, DatabaseSettingsPageKeeShare) have been removed. Instead the widgets are used directly in DatabaseSettingsDialog. Same could be done later to Application 

---------

Co-authored-by: Jonathan White <[email protected]>
2024-06-22 07:25:32 -04:00
Carlo Teubner 88b76244cf Fix all Qt 5.15 deprecation warnings (#7783)
* Deprecated qSort() -> std::sort()
* Replace QDateTime::toString(Qt::DefaultLocaleShortDate) with Clock::toString()
* Replace QDateTime::toString(Qt::SystemLocaleShortDate) with QLocale::system().toString(..., QLocale::ShortFormat)
* Use QDateTime::startOfDay() instead of QDate(QDateTime) 
  Note: QDateTime::startOfDay() is only available in Qt 5.14, we need to guard it
* Replace QString::SkipEmptyParts with Qt::SkipEmptyParts
  Note: Its designated replacement, Qt::SplitBehavior, was only added in Qt 5.14.
* Don't call deprecated QFlags(nullptr) constructor
* QSet::{toList->values}
* Replace QList::toSet, QSet::fromList with Tools::asSet()
* QHash::insertMulti -> QMultiHash::insert
* QProcess::startDetached: non-deprecated overload
* QProcess::{pid->processId}
* QPainter::{HighQuality->}Antialiasing
* QPalette::{background->window}()
* Use Qt::{Background,Foreground}Role
* endl -> Qt::endl, flush -> Qt::flush
* Make YubiKey::s_interfaceMutex non-recursive
* OpenSSHKeyGenDialog: use non-deprecated QComboBox::sizeAdjustPolicy setting
2024-06-22 07:22:44 -04:00
Carlo Teubner 07f565aa49 Require Qt >= 5.12
Bump the minimum required Qt version up to 5.12, as per
https://github.com/keepassxreboot/keepassxc/issues/10859#issuecomment-2148477826.
Previously, the minimum version was 5.2.0 based on the CMakeLists.txt
check, though it's unclear if such old versions would actually work.

With this, we are able to remove a whole bunch of #ifdef'd code.
2024-06-22 00:01:23 -04:00
AgostonSzepessy 1f9c25cc91 Show character count in password generator dialog (#10940)
Displays the number of characters in the password field in the password generator dialog. This fixes #10858.
2024-06-21 23:53:18 -04:00
Carlo Teubner 9972b5f531 Fix Copy Password button when text is selected (#10853)
When the user chooses to copy the password for an entry to the clipboard, previously there was logic to check if text was selected, and if so, that text was instead copied to the clipboard. That made sense if
(a) the user invoked the Copy Password action via its keyboard shortcut, and (b) that keyboard shortcut was configured (as per default) to be Ctrl-C, i.e. the same as the system action for copy-to-clipboard.

However, it made no sense if the user invoked that action in some other way, for example by clicking the corresponding toolbar button.

It also made no sense in the case that the Copy Password action had some other keyboard shortcut assigned. Also, if some other action had Ctrl-C assigned, the logic would not kick in then.

Fix all of the above by modifying the keyboard shortcut logic to intervene precisely in the case where a shortcut is pressed that matches the system copy-to-clipboard shortcut; only in that case do we now check if text is selected and if so copy that to the clipboard instead of the action we would otherwise take.

Fixes #10734.
2024-06-19 08:03:42 -04:00
Carlo Teubner 24dc07897b Search entry: respect shortcut config on Copy key
If the system Copy key sequence (i.e. Ctrl+C or Cmd+C) is pressed while
inside the search entry without any text being selected, previously we
would copy the currently selected entry's password. This made sense when
keyboard shortcuts were fixed. Now that they are configurable, change it
to re-route the event to the main window, which can then take the
appropriate action (i.e. Ctrl+C might be bound to some other action).
2024-06-16 17:38:29 -04:00
Jonathan White 2c0844807e Improve overall database settings behavior
* Fixes #10723 - only display password strength warning when actively editing the password
* Also improve behavior of minimum quality warning
* Improve behavior and handling of password changes with the database settings dialog
* Prevents loss of newly entered password when toggling between elements in the settings page
* On error, switch to tab that prevents saving database settings for easier correction
2024-06-16 08:43:09 -04:00
Jonathan White 2b08af712f Fix encryption settings behavior
* Fixes #10558
2024-06-16 08:43:09 -04:00
Carlo Teubner af2ba798a0 TestGui: testTotp: use QTRY_COMPARE
That test failed, presumably because of inherent raciness: https://ci.keepassxc.org/buildConfiguration/KeePassXC_MacOS/248424?expandBuildDeploymentsSection=false&hideTestsFromDependencies=false&hideProblemsFromDependencies=false&expandBuildChangesSection=true&expandBuildProblemsSection=true&showLog=248423_1081_942&logFilter=debug&logView=flowAware

Paper over the raciness by using QTRY_COMPARE instead of QCOMPARE.
2024-06-14 18:08:08 -04:00
1ca607792d Support remote database access using external tools (#7222)
* Provide remote database sync capability

Allow arbitrary commands to be defined and executed for syncing databases with remote services. This includes sftp, scp, rsync, etc. 

Remote commands are stored per-database and sync operations are manually triggered by the user from the Database -> Remote Sync menu. 

---------

Co-authored-by: Stefan Forstenlechner <[email protected]>
Co-authored-by: Jonathan White <[email protected]>
2024-06-13 06:23:41 -04:00
Jonathan White 5513ff5c1f Fix TestCli and TestGui entropy tests across platforms
* zxcvbn wordlists can vary between platforms depending on packager adjustments (ie, zxcvbn-c vs Ubuntu Focal)
2024-03-31 07:56:23 -04:00
Jonathan White e700195f0a Add 1Password 1PUX and Bitwarden JSON Importers
* Closes #7545 - Support 1Password 1PUX import format based on https://support.1password.com/1pux-format/

* Closes #8367 - Support Bitwarden JSON import format (both unencrypted and encrypted) based on https://bitwarden.com/help/encrypted-export/

* Fixes #9577 - OPVault import when fields have the same name or type

* Introduce the import wizard to handle all import tasks (CSV, KDBX1, OPVault, 1PUX, JSON)

* Clean up CSV parser code to make it much more efficient and easier to read

* Combine all importer tests (except CSV) into one test file
2024-03-09 10:44:54 -05:00
Janek Bevendorff 0acb15de0f Set test locale to C 2024-03-08 10:55:22 -05:00
Janek Bevendorff 6a273363c4 Automatically detect USB device changes 2024-03-08 10:55:22 -05:00
Waqar AhmedandJonathan White a472ef8a93 Allow configuring keyboard shortcuts (#9643)
Closes #2689

The design of the respective code is loosely based on KDE's KActionCollection. The ActionCollection manages all actions that can be shortcut configured. These actions are then exposed in the config and a user can assign a different shortcut.

Actions inside the MainWindow have been added to the ActionCollection.

---------

Co-authored-by: Jonathan White <[email protected]>
2024-02-04 06:29:04 -05:00
egglessness d44486ce94 Add configurable password strength check on database password (#9782)
* Set default value of DatabasePasswordMinimumQuality to 3 (do not accept a master password that is less than Good)

* Add custom message box button "Continue with weak password"
2024-01-06 13:53:18 -05:00
Colfenor cd7a53abbb Fix first entry is not selected when a search is performed (#9868) 2023-09-25 09:21:28 -04:00
Jonathan White eee25a1c35 Fix several issues with Quick Unlock (#9697)
* Fix #7892 - Pressing escape when the quick unlock prompt is shown will now go back to the main unlock dialog view.
* Fix #9030 - Quick unlock will be automatically invoked in the unlock dialog upon being shown.
* Fix #9554 - Quick unlock application setting will be updated every time the settings widget is shown instead of just on first launch.

* Show warning that quick unlock is not enabled if user cancels Windows Hello prompt. This should limit people thinking there is a security issue. Also improve documentation describing this behavior.

* Disable quick unlock in gui tests
2023-08-10 08:21:08 -04:00
Jonathan White 3cf14971f2 Improve database encryption settings UX
Fixes #6190

Remove the advanced settings checkbox and replace with a dedicated tab widget interface to toggle between basic and advanced encryption settings.
2023-07-09 12:29:56 -07:00
jNulljandjNullj 35baeaff79 Add auto-save delay per database (#9100)
Add a new propery autosaveDelay in Metadata of the db.
The property is saved in customData to not affect database structure as this setting is unique to keepasxc.
The propery sets delay to wait since last modification before saving.

Co-authored-by: jNullj <[email protected]>
2023-07-08 08:49:03 -04:00
jNulljandjNullj e755ee8e04 test: add test for maximum history in database settings (#9176)
This commit adds a test to the TestGui::testDatabaseSettings function for the history maximum items and maximum size settings.
The test opens the database settings dialog, disables the history items and size settings, saves the changes, reopens the dialog, and then cancels without making any changes to load the default values. The test ensures that the default values are loaded correctly.

Co-authored-by: jNullj <[email protected]>
2023-07-04 05:43:12 -07:00
Jonathan White e701ccbd73 Fix GUI tests on macOS 2023-04-30 09:26:33 -04:00
jNulljandjNullj 7a6505626f Fix TestGui::testDatabaseSettings open tab missing (#9162)
Co-authored-by: jNullj <[email protected]>
2023-02-25 14:11:18 -05:00
Jonathan White 8dec687798 Correct testing status bar text 2023-02-19 08:28:12 -08:00