KWallet
KWallet is a secure credential storage framework developed by the KDE project for the Plasma desktop environment, providing encrypted storage for passwords, keys, and other sensitive data across KDE applications and services.[1][2] It functions as a centralized password manager, allowing users to store secrets such as Wi-Fi passphrases, SSH keys, Git credentials, and application-specific passwords in protected wallet files, typically located in ~/.local/share/kwalletd as .kwl files encrypted with algorithms like Blowfish.[2][3]
The framework consists of three main components: the core KWallet interface for password storage, the kwalletd daemon that exposes the KWallet API and proxies requests to Secret Service providers, and ksecretd, which implements the standardized org.freedesktop.secrets DBus API for broader compatibility with applications since KDE Frameworks 5.97.0.[1][2] KWalletManager serves as the primary graphical tool for users to create, access, and manage these wallets, integrating seamlessly with KDE Plasma to handle credential prompts and automate storage for integrated software like web browsers, email clients, and network tools.[4][2] It supports features such as automatic unlocking upon login via PAM integration (using the kwallet-pam module when the wallet password matches the user login password) and migration to third-party Secret Service backends for enhanced flexibility.[1][3][2]
As an open-source solution written primarily in C++, KWallet emphasizes security by keeping sensitive data off unencrypted disks and requiring user authentication for access, though it can be configured to disable certain components like ksecretd if needed.[1][2] It acts as the KDE counterpart to GNOME Keyring but remains incompatible with it, focusing on the KDE ecosystem while adhering to the Freedesktop Secret Service standard for interoperability where possible.[3] Actively maintained by the KDE community with contributions from numerous developers, the latest stable release of KWalletManager as of November 2025 is version 25.08.3, ensuring ongoing support for modern Plasma versions and security updates.[4][1]
Overview and History
Introduction
KWallet is a free and open-source password management framework developed by the KDE community for Unix-like operating systems, with a primary focus on Linux desktop environments.[1][4] It provides a secure system for storing sensitive credentials, such as passwords, usernames, and form data, organized into encrypted wallets that users protect with a single master password.[5] This design enables efficient management of multiple secrets while minimizing the need to remember individual passwords for various applications.[5]
In KWallet, wallets function as secure containers for grouping related secrets, allowing users to create multiple wallets for better organization—for instance, separating local application passwords from network credentials.[5] The default wallet, named "kdewallet," is specifically tailored for use by KDE applications and can be automatically unlocked at login on supported distributions via the kwallet-pam integration.[5] For encryption, KWallet employs the Blowfish algorithm with a 160-bit key and SHA-1 hashing by default, or GPG encryption using passphrase-protected keys for enhanced security when a GPG keypair is available.[5][6]
Applications access KWallet's stored data through its API, which triggers an unlock prompt if the relevant wallet is locked, ensuring controlled retrieval of credentials.[1] As of November 2025, KWallet is fully integrated into KDE Plasma 6.x as part of the KDE Frameworks, with ongoing development emphasizing a transition to the Freedesktop Secret Service API to serve as a compatibility layer and improve interoperability with other desktop environments.[7][8]
Development and Releases
KWallet originated in 2003 as part of KDE's initiative to provide a centralized, secure storage system for passwords and sensitive data, aiming to standardize and replace scattered password handling across KDE applications.[9]
The project has been primarily maintained by the KDE development team, with significant contributions from volunteers in the open-source community.[10]
Major releases aligned with KDE's broader version cycles, incorporating enhancements for security and integration. In the KDE 4 series, starting with the 2008 initial release, KWallet gained a GnuPG backend in version 4.12 (2013), enabling asymmetric encryption for stored credentials using user GPG keys.[11] KDE Frameworks 5.97 in August 2022 introduced support for the standard Secret Service DBus API for better interoperability with desktop applications.[1][12] Plasma 5.20 and later versions from 2020 onward enhanced Wayland compatibility, ensuring reliable operation in Wayland sessions through updated daemon handling and session management.[13] With Plasma 6.0's release in February 2024, KWallet incorporated updates from KDE Gear 24.02, focusing on modern Qt6 support; this was followed by bug fixes in Plasma 6.2.5, released on December 31, 2024.[14][15]
In 2025, KDE developers initiated discussions on migrating from KWallet to the cross-desktop Secret Service standard, as outlined in an April blog post by Marco Martin, including the development of compatibility client applications; however, no full deprecation of KWallet has occurred as of November 2025.[7]
KWallet is licensed under the GNU General Public License version 2 or later, with its source code hosted in the KDE Git repository at invent.kde.org/frameworks/kwallet.[16][17]
Features and Integration
Core Functionality
KWallet organizes secrets into logical groupings called wallets, where each wallet serves a specific purpose, such as the default "kdewallet" for storing Plasma desktop settings and general application credentials, or dedicated wallets like "Chrome" for browser-related data.[2][18] These wallets support various entry types, including simple text-based passwords, key-value maps for structured data, and binary blobs for application-specific content, enabling flexible storage of diverse secrets.[19]
Applications access and manage these secrets through the KWallet API, which communicates with the kwalletd daemon service to handle storage and retrieval requests securely over D-Bus.[1] For user convenience, the kwallet-pam module integrates with the Pluggable Authentication Modules (PAM) system during login, automatically unlocking the default wallet if its password matches the user's login credentials, thus enabling seamless access without additional prompts after authentication.[2] This PAM-based autounlock extends to cross-application usage, allowing diverse KDE components and third-party apps to query shared secrets, such as network credentials or authentication tokens, without redundant password entry.[20]
Core features enhance usability within the KDE ecosystem, including auto-fill functionality for web forms and login credentials in applications like Konqueror, which retrieves stored data to populate fields automatically.[21] Wallets support export and import operations in the encrypted .kwl file format via KWalletManager, facilitating secure transfer or recovery of secrets between systems.[22] Additionally, kwalletmanager5 provides backup capabilities by allowing users to generate encrypted archives of entire wallets or specific entries, ensuring data preservation against loss.
Integration with Plasma desktop components is native and extensive, exemplified by NetworkManager's use of KWallet to persistently store WiFi passwords and connection secrets, enabling automatic reconnection to known networks.[23] Similarly, KMail leverages KWallet for managing email account passwords and related form data, streamlining authentication for mail transport protocols like POP3 or IMAP.
During the KDE Plasma 6 series, particularly from version 6.3 (February 2025) onward, KWallet includes an enhanced compatibility mode for the Freedesktop.org Secret Service API, which can proxy requests to alternative providers like GNOME Keyring, permitting hybrid usage and gradual transitions without full data migration.[7][2]
Browser and Application Integration
KWallet provides integration with various web browsers to securely store and retrieve passwords, leveraging its DBus-based interface for password management. Chromium-based browsers such as Google Chrome, Microsoft Edge, and Opera support KWallet through command-line flags that specify it as the password store backend. Users can launch these browsers with the --password-store=kwallet5 or --password-store=kwallet6 flag (the latter for Plasma 6 environments) to enable direct access to KWallet for form data and credentials, or use --password-store=detect for automatic detection of available backends.[2] These flags ensure that passwords saved in the browser are encrypted and stored within KWallet's secure containers, with persistent configuration achievable by adding them to the browser's desktop file or shortcut properties.[2]
KDE's native browsers, Falkon and Konqueror, offer seamless integration with KWallet without additional setup, as they are built on Qt and KDE Frameworks. Falkon includes a built-in password manager that can store credentials directly in KWallet's encrypted databases, supporting both encrypted and non-encrypted backends for flexibility.[24] Similarly, Konqueror utilizes KWallet for handling web form passwords and authentication, providing native prompts for unlocking the wallet when needed. For Mozilla Firefox, official extension support ended after version 57 in 2017 due to changes in the browser's extension architecture, but legacy extensions like the KDE Wallet Password Integration addon remain available for older profiles or via manual installation.[25] Advanced users can achieve integration post-v57 through manual DBus bridging, where Firefox's password storage is scripted to interact with KWallet's service via custom tools or environment configurations, though this requires technical setup and is not officially supported.[26]
Beyond browsers, KWallet integrates with third-party applications through the Secret Service DBus interface, a standard API introduced in KDE Frameworks 5.97 for cross-desktop compatibility.[2] This allows non-KDE applications, such as GNOME software running on Plasma, to access KWallet as a keyring provider via the org.freedesktop.secrets service, enabled by creating a DBus service file at ~/.local/share/dbus-1/services/org.freedesktop.secrets.service pointing to kwalletd6.[2] A compatibility layer in KWallet facilitates this bridging, ensuring that applications expecting GNOME Keyring functionality can store and retrieve secrets without modification.[7]
Setup for broader application integration involves environment variables and PAM modules for automation. For custom or command-line applications, variables like SSH_ASKPASS=/usr/bin/ksshaskpass and GIT_ASKPASS=/usr/bin/ksshaskpass direct tools such as SSH and Git to use KWallet-compatible prompts for passphrase entry.[2] Autounlocking on login in the SDDM display manager is configured via the kwallet-pam package (using pam_kwallet6.so in Plasma 6), adding lines like auth optional pam_kwallet6.so and session optional pam_kwallet6.so auto_start to PAM configuration files such as /etc/pam.d/sddm.[2] The KDEWALLET_INTERFACE environment variable can further customize the DBus interface for specific applications, allowing selection between legacy KWallet and Secret Service modes.[7]
As of KDE Plasma 6.5 (October 2025), the transition to the Secret Service API continues, with tools like a dedicated Secret Service client application enhancing support for multiple providers.[7][27] This evolution maintains backward compatibility while promoting standardized secret management across Linux desktops.[7]
Installation and Setup
System Requirements and Installation
KWallet requires a Linux kernel-based operating system, with full compatibility ensured on distributions supporting the KDE Plasma desktop environment version 5.0 or later; for optimal performance in 2025, KDE Plasma 6.x is recommended.[2][4] Key dependencies include Qt 5 or Qt 6, KDE Frameworks 5 or 6, and optionally GnuPG for GPG-based encryption mode, which enhances integration with tools like KGPG.[17][28] These prerequisites ensure seamless operation within the KDE ecosystem, handling password storage via the Frameworks wallet subsystem.[4]
Installation is straightforward using native package managers on major Linux distributions. On Debian-based systems like Ubuntu, users can install via sudo apt install kwalletmanager, which pulls in the necessary kwallet libraries and manager tools. For Arch Linux and derivatives, the command sudo pacman -S kwallet provides the core subsystem, with kwalletmanager available optionally for graphical management.[2] KWallet is pre-integrated in KDE-focused spins such as Kubuntu and Fedora KDE, requiring no additional steps beyond the base desktop installation.[29][2]
For containerized deployment, KWalletManager is available as a Flatpak package through Flathub with the identifier org.kde.kwalletmanager5, installable via flatpak install flathub org.kde.kwalletmanager5.[30] This method works across distributions, including non-KDE environments like GNOME, where manual enablement can be achieved by ensuring the kwallet D-Bus service is active for secret service compatibility.[2] Advanced users may build from source using CMake, cloning the repository from KDE's GitLab at https://invent.kde.org/frameworks/kwallet and following standard KDE build instructions with dependencies like extra-cmake-modules.[17]
Post-installation, KWallet creates a default wallet automatically upon first use by KDE applications, prompting for a master password. In KDE Plasma 6 environments as of 2025, enabling automatic unlocking on login necessitates the kwallet-pam module, configured via PAM for integration with display managers like SDDM.[2][31] Further configuration, such as wallet creation details, is handled separately after installation.[4]
Initial Configuration
Upon first login to a KDE Plasma session after installing KWallet, the system prompts the user to create the default wallet named "kdewallet" when an application requests access to stored credentials.[2] This initial setup requires setting a master password to encrypt the wallet, with options to use classic Blowfish encryption (the default for compatibility) or GPG encryption for enhanced protection via a user-generated keypair.[2][32]
Basic preferences for KWallet are configured through System Settings > KDE Wallet, where users can enable automatic unlocking tied to the login password (requiring PAM integration), set a timeout for automatic locking after inactivity, and activate the Secret Service API to support non-KDE applications.[2][33] The Secret Service support, available since KDE Frameworks 5.97, allows broader compatibility by exposing KWallet as a standards-compliant keyring.[2]
As of April 2025, KWallet underwent architectural changes in KDE Plasma 6: the services were split, with the old KWallet service now acting as a pure Secret Service provider using the legacy backend, and a new compatibility wrapper translating calls from the traditional KWallet API to the Secret Service API. This facilitates a gradual transition for applications to the cross-desktop Secret Service standard via libraries like QtKeychain. For users wishing to migrate to a third-party Secret Service provider (e.g., KeepassXC), an experimental option is available by setting [Migration] MigrateTo3rdParty=true and [KSecretD] Enabled=false in kwalletrc, provided a compatible DBus-activatable provider is configured. Existing secrets remain accessible without immediate changes.[7]
For seamless synchronization with user login, PAM integration is achieved by installing the kwallet-pam package and editing configuration files such as /etc/pam.d/sddm or /etc/pam.d/login to include the pam_kwallet5.so module, ensuring the KWallet password matches the user login password.[2][34]
Migration tools in KWalletManager facilitate importing from older KWallet versions (e.g., KDE4) via a built-in assistant that copies data from ~/.kde/share/apps/kwalletd to the modern location at ~/.local/share/kwalletd.[35] For GNOME Keyring, direct import is not natively supported, but users can manually export secrets from GNOME applications and re-enter them into KWallet, or use KWalletManager's export function to back up data as a CSV file for portability.[36][37]
User Interface and Management
Graphical Interface
The KWalletManager application serves as the primary graphical user interface (GUI) for interacting with KWallet, allowing users to visually manage encrypted password storage on KDE Plasma systems. Built using the Qt framework, it presents a multi-pane window that facilitates intuitive navigation and operations on wallet contents. The interface opens to a main view displaying available wallets in a left-hand list, where each wallet's status—such as locked or unlocked—is indicated by visual icons, including a padlock symbol for locked states. Selecting a wallet expands its structure in the central area, revealing folders and entries without immediately exposing sensitive data.[38]
Core components include a wallet list view for selecting and switching between multiple wallets, an entry browser that displays secrets organized by folders or applications, and a dedicated search bar for filtering contents by keywords, folder names, or associated applications. The contents tab features a tree-like structure for browsing folders—such as default ones for passwords and form data—alongside a details pane that hides values by default; users can toggle visibility using the "Show Values" button to reveal or obscure entries securely. The applications tab lists connected programs, enabling users to monitor and control access permissions. These elements support drag-and-drop functionality for moving folders and entries between wallets, enhancing workflow efficiency.[38][2]
Common operations are accessible via toolbar buttons and context menus, including unlock and lock actions that prompt for the master password to access or secure a wallet, as well as add, edit, and delete functions for creating new entries (such as key-value pairs or passwords) or removing existing ones. Users can change the master password through the wallet's properties dialog, which also allows setting access rules for specific applications. For advanced management like backups, the interface provides export and import functions to handle encrypted wallet files.[38][2]
As a Qt-based application, KWalletManager supports high-DPI displays through Qt's scaling capabilities and operates seamlessly under Wayland compositors in KDE Plasma, ensuring crisp rendering on modern hardware without additional configuration. It includes keyboard shortcuts for key actions, such as Ctrl+N for new entries and Ctrl+O for opening wallets, aligning with standard Qt conventions to aid accessibility for keyboard-only navigation. The latest version, 25.08.3, was released on November 6, 2025.[4][39]
KWallet provides several administrative tools for creating, deleting, and managing wallets, primarily through the graphical KWallet Manager (kwalletmanager5) and command-line utilities. To create a new wallet, users launch kwalletmanager5 and select the option to create a wallet, specifying a name and encryption settings, while deletion is performed by selecting an existing wallet and choosing the delete action, which permanently removes the wallet file after confirmation.[38] Permissions for application access are configured within kwalletmanager5 under the wallet's Applications tab, where users can authorize specific applications to read or write to the wallet without repeated prompts, enhancing control over sensitive data access.[40]
Backup and restore operations rely on the encrypted .kwl wallet files stored in ~/.local/share/kwalletd by default. Users export a wallet by unlocking it in kwalletmanager5 and saving a copy of the .kwl file, which remains encrypted and portable for secure transfer. Restoration involves using the File > Import Wallet menu in kwalletmanager5 to load the .kwl file, entering the master password to merge or replace contents, while for bulk migration scenarios, community scripts like kwallet-dump can extract entries from older .kwl files for scripted import into new wallets.[2][22]
Monitoring wallet activity and integrity is facilitated through system logs and query tools. Logs for the kwalletd daemon, which handles wallet operations in the background, can be viewed using journalctl -u kwalletd to track errors, access attempts, or service events. For non-graphical querying, the kwallet-query command-line tool allows inspection of wallet entries without launching the GUI, such as listing contents in a specific folder with options like kwallet-query -f FolderName -l kdewallet.[41][42]
Support for multiple wallets enables compartmentalization, such as designating separate wallets for work and personal use, with applications assigned to specific ones via access policies in kwalletmanager5 to prevent cross-contamination of secrets. Best practices include regularly reviewing authorized applications and using distinct master passwords for each wallet to minimize risk. As part of ongoing efforts in 2025 to integrate KWallet as a Secret Service provider, experimental support for dynamic wallet switching through the DBus interface is in development, potentially allowing applications to request access to specific collections (wallets) on-the-fly.[2][7]
Security and Encryption
Encryption Mechanisms
KWallet employs two primary encryption modes to secure stored credentials: a symmetric Blowfish-based approach and an asymmetric GPG-based method, allowing users to select the preferred mechanism during wallet creation or configuration.[5]
In the Blowfish mode, data is protected using the Blowfish symmetric block cipher in Cipher Block Chaining (CBC) mode, with a key of up to 448 bits (56 bytes) derived from the master password. The key derivation process functions as a password-based key derivation function (PBKDF) utilizing iterated SHA-1 hashing without salt, where the password is divided into 16-character blocks, each hashed 2000 times with SHA-1, and the results concatenated and truncated to 56 bytes for the Blowfish key. This can be expressed as:
\text{DerivedKey} = \text{PBKDF}(\text{MasterPassword}, \text{Iterations}=2000, \text{Hash}=\text{SHA-1}, \text{KeyLength}=448 \text{ bits})
Data integrity is ensured via SHA-1 authentication prior to decryption. A 2013 security analysis highlighted vulnerabilities in this setup, including the lack of salt, reliance on the deprecated SHA-1, and potential effective ECB behavior due to implementation quirks in CBC usage, though subsequent KDE versions have addressed some implementation issues. As of 2025, the key derivation function has not been updated to include salt or modern hashing, preserving vulnerabilities to precomputed attacks.[43][6][2]
The GPG mode leverages asymmetric encryption through the GNU Privacy Guard (GnuPG) framework, requiring the gpgme library for integration and a user-generated keypair for enhanced protection. This approach uses strong, passphrase-protected GPG keys to encrypt wallet contents, providing superior security compared to Blowfish by employing modern algorithms like RSA or ECC for key exchange and AES for bulk encryption, as configured in the user's GPG setup.[5][44]
Wallets in both modes are stored as encrypted binary files (typically with .kwl extension) in the directory ~/.local/share/kwalletd/, where each file represents an encrypted blob containing serialized data via Qt's QDataStream format; the header includes metadata such as the wallet's creation date and format version for compatibility.[2][43]
Users can switch between modes via the KWalletManager preferences, with GPG recommended in 2025 due to identified weaknesses in Blowfish, including its smaller effective key strength against brute-force attacks and the deprecation of SHA-1 in key derivation.[32][43]
Security Architecture
KWallet's security architecture emphasizes confinement to the user session and layered protections to safeguard stored credentials against unauthorized access. The system daemon, kwalletd5, operates exclusively within the D-Bus session bus of the logged-in user, ensuring that wallet operations are isolated from system-wide processes or other user sessions. This design inherently blocks root access to wallets, as the daemon lacks privileges to interact beyond the originating user's context.[1][2]
Access controls are further reinforced through application-specific policies managed via the KWalletManager tool, which presents a tree view of requesting applications and allows users to approve or deny access on a per-app basis. When an application seeks wallet access, KWallet prompts the user for confirmation unless a prior policy grants permission, thereby preventing unauthorized retrieval of secrets even from trusted software running in the same session. These policies apply wallet-wide, granting approved applications read access to all contained entries without finer-grained controls.[40]
Key management in KWallet prioritizes ephemerality and session-bound handling, with the master password retained solely in volatile memory during an active unlocked state to minimize exposure risks. The architecture includes an auto-lock mechanism that re-secures the wallet after configurable periods of inactivity or when no applications are actively using it, forcing re-authentication for subsequent access. This approach aligns with broader KDE security principles by reducing the window of vulnerability during idle periods.[22][45]
Audit capabilities provide visibility into potential threats, as KWallet logs access attempts and alerts users to repeated failures, indicating possible malicious activity or misconfiguration. Integration with systemd enhances session management through the kwallet-pam module, which ties wallet unlocking to the authentication process during login, ensuring synchronization with the system's user session lifecycle.[46][2][47]
Hardware-backed security remains an evolving aspect, with experimental support for Trusted Platform Modules (TPM) and secure elements discussed in KDE developer forums since 2024 to enable protected key storage and passwordless unlocking.[48]
KWallet also incorporates GPG integration for advanced cryptographic operations, enabling wallets to be encrypted using user-generated GPG keypairs instead of solely symmetric methods, which supports public-key workflows while maintaining compatibility with the core architecture.[22]
Vulnerabilities and Best Practices
Known Security Issues
KWallet has faced several documented security vulnerabilities over its history, primarily related to encryption weaknesses and local privilege escalation risks.
In versions prior to KDE Applications 14.12.0, kwalletd employed the Blowfish cipher in ECB mode for encrypting the password store, which facilitated codebook attacks by attackers attempting to guess contents through pattern analysis in ciphertext blocks.[49] This issue was mitigated in KDE Applications 14.12.0 by switching to CBC mode, enhancing resistance to such attacks.[49]
Pre-2018 implementations of KWallet relied on SHA-1 for key derivation from user passwords, splitting the password into 16-character blocks and applying SHA-1 2000 times per block without salting, resulting in a weak 56-bit effective key strength for Blowfish encryption and potential vulnerability to brute-force or collision attacks.[43] These weaknesses exposed authentication bypass risks in older versions, particularly when combined with the lack of salt and short key lengths.[6] As of November 2025, KWallet continues to use SHA-1 for key derivation, and users are advised to employ strong master passwords to mitigate associated risks.[5]
A significant local privilege escalation vulnerability affected kwallet-pam in KDE KWallet versions before 5.12.6, where a symlink attack allowed unprivileged users to gain ownership of arbitrary files during PAM integration, potentially enabling unauthorized access to sensitive data.[50] This was resolved in version 5.12.6 through improved file handling and permission checks.[50]
In KDE kio-extras up to version 20.04.0, the fish protocol implementation in fish/fish.cpp invoked cacheAuthentication without verifying the keepPassword option, leading to unintended storage of credentials in KWallet and increasing exposure risks for remote file access sessions.[51] The flaw was patched in subsequent releases by adding proper option validation.[51]
As of November 2025, no major CVEs have been reported for KWallet in 2024 or 2025, though integration challenges persist. For instance, kwallet-pam in early Plasma 6.1 releases (June 2024) exhibited startup issues related to libgcrypt compatibility that prevented automatic wallet unlocking, potentially leading to repeated authentication prompts and indirect security annoyances, which were addressed in updates by July 2024.[52] Ongoing migration efforts from KWallet to the Secret Service API, initiated in early 2025, introduce transition risks such as temporary data exposure if migration procedures fail to lock or transfer secrets properly, as noted in KDE developer discussions.[53]
Additionally, Chromium-based browser integrations with KWallet have prompted user reports of persistent authentication popups, though no verified spoofing vulnerabilities were confirmed; a December 2024 patch in KDE Frameworks improved popup handling to reduce false prompts without introducing new risks.[54]
Mitigation and Best Practices
To enhance the security of KWallet, users should prioritize strong password hygiene for the master password that protects the wallet. Select a unique, lengthy passphrase—at least 20 characters combining uppercase, lowercase, numbers, and symbols—to resist brute-force attacks, and avoid reusing it across other services.[2] For added protection, separate sensitive data into multiple wallets, such as one for local application credentials and another for network-related secrets like Wi-Fi or SSH keys, minimizing the impact of any single compromise.[29] Avoid empty or weak master passwords, as they expose stored secrets to unauthorized access if the system is breached.[2]
To implement two-factor authentication, integrate KWallet with Pluggable Authentication Modules (PAM) and hardware tokens, such as TPM or FIDO2 keys, ensuring the wallet password aligns with the login credentials for seamless unlocking while requiring a second factor for initial access.[48] This setup leverages PAM modules like pam_u2f for hardware verification during login, indirectly securing wallet access without manual re-entry.[55]
In configuration, disable automatic unlocking on multi-user or shared systems to prevent unintended access; edit the PAM configuration (e.g., in /etc/pam.d/sddm) to remove kwallet-pam integration or set distinct passwords, and enable the "Prompt when an application accesses a wallet" option in KWallet Manager's Access Control settings.[2] Regularly back up wallets by copying the encrypted .kwl files from ~/.local/share/kwalletd to a secure, off-system location, then verify integrity by unlocking the restored wallet in KWallet Manager and inspecting entries for completeness.[2]
For ongoing monitoring, configure auditd to log access attempts to the kwalletd directory by adding rules in /etc/audit/rules.d/audit.rules (e.g., -w /home/username/.local/share/kwalletd -p wa -k kwallet-access), then review logs with ausearch for suspicious activity.[56] Always update to the latest KDE Plasma release, as it incorporates security patches for KWallet vulnerabilities, such as those addressed in KDE Security Advisories.[57]
With the 2025 transition to the Freedesktop Secret Service API, KWallet now functions primarily as a compatibility provider; users should test the migration by enabling the experimental feature in ~/.config/kwalletrc (MigrateTo3rdParty=true) in a non-production wallet to ensure data portability to providers like KeepassXC before disabling the legacy KWallet backend.[7]
API and Extensibility
Programming Interfaces
KWallet provides developers with interfaces primarily through the D-Bus protocol and C++ classes for seamless integration into KDE applications and beyond. The core D-Bus interface, org.kde.KWallet, is exposed by the kwalletd daemon at the object path /modules/kwalletd, enabling inter-process communication for wallet operations.[58]
Key methods in this interface include openWallet(QString walletName, uint wId, int openType), which initiates access to a wallet either synchronously or asynchronously, returning a handle for further interactions; writePassword(QString folder, QString key, QString password), which stores a password value in a specified folder and key; and corresponding readPassword(QString folder, QString key) for retrieval, which returns the stored value or an error if not found. Additional methods support folder management, such as createFolder(QString folderName, int permissions) and deleteFolder(QString folderName), as well as closeWallet() to release resources. These methods handle binary data via QByteArray for general entries, with error signals emitted for conditions like locked wallets or invalid credentials. The methods often require an application identifier (appid) parameter to track usage by specific applications.[59]
For C++ development in KDE applications, the KWallet::Wallet class offers a convenient abstraction over the D-Bus calls, simplifying wallet handling. Developers link against the KF6::Wallet library using CMake's find_package(KF6 REQUIRED COMPONENTS Wallet) and target_link_libraries(target KF6::Wallet). The class supports opening wallets with static Wallet* openWallet(const QString& name, WId parent, [OpenType](/page/OpenType) type), where type can be Synchronous or Asynchronous, followed by operations like writePassword(const QString& folder, const QString& key, const QString& value) or readPassword(const QString& folder, const QString& key, QString* value). If the wallet is locked, these methods return error codes such as Wallet::Locked, prompting developers to implement retry logic or user notifications. A basic example demonstrates usage:
cpp
#include <KWallet/Wallet>
KWallet::Wallet* wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0, KWallet::Wallet::Synchronous);
if (wallet && wallet->isOpen()) {
int result = wallet->writePassword("ApplicationFolder", "userCredential", "secureValue");
if (result == 0) {
qDebug() << "Password stored successfully.";
}
delete wallet;
}
#include <KWallet/Wallet>
KWallet::Wallet* wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0, KWallet::Wallet::Synchronous);
if (wallet && wallet->isOpen()) {
int result = wallet->writePassword("ApplicationFolder", "userCredential", "secureValue");
if (result == 0) {
qDebug() << "Password stored successfully.";
}
delete wallet;
}
This approach ensures thread-safe access and integrates with KDE's notification system for user prompts.[60][59]
Python developers can access KWallet via the dbus-python library to invoke the org.kde.KWallet methods directly, providing a scriptable entry point without native bindings. For instance, a script might connect to the bus, call openWallet, and store entries using DBus proxies. Legacy support existed through PyKDE's KWallet.Wallet class, but modern usage favors DBus or cross-platform libraries like QtKeychain for compatibility. Error handling mirrors the C++ API, with exceptions raised for locked states, allowing graceful fallbacks like prompting the user via KDE dialogs.[61]
As of Plasma 6.2 (October 2024), KWallet has improved adherence to the Freedesktop Secret Service DBus specification (org.freedesktop.secrets), enabling use as a backend for standards-compliant tools like Seahorse or Python's SecretStorage module. The legacy org.kde.KWallet interface persists as a thin wrapper translating calls to the Secret Service API, ensuring backward compatibility while supporting migration to alternative providers. This dual-interface design broadens developer options without disrupting existing KDE integrations.[7][62]
Developer Usage Examples
Developers can integrate KWallet into applications using its C++ API for secure credential storage, particularly in KDE-based environments. The API allows for opening wallets, writing and reading entries, and managing folders asynchronously to avoid blocking the user interface.[19]
A basic C++ example demonstrates opening the default wallet and writing a username-password pair. First, include the necessary headers and link against KDE libraries via CMake. The code snippet below opens the "kdewallet" asynchronously, checks if successful, and writes an entry to a custom folder:
cpp
#include <KWallet/Wallet>
#include <QApplication>
#include <QDebug>
int main(int argc, char **argv) {
QApplication app(argc, argv);
WId winId = 0; // Replace with actual window ID if needed
KWallet::Wallet *wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), winId, KWallet::Wallet::Synchronous);
if (wallet && wallet->isOpen()) {
if (!wallet->hasFolder("MyAppFolder")) {
wallet->createFolder("MyAppFolder");
}
wallet->setFolder("MyAppFolder");
wallet->writePassword("", "user", "password");
qDebug() << "Entry written successfully.";
wallet->deleteLater();
} else {
qDebug() << "Failed to open wallet.";
}
return app.exec();
}
#include <KWallet/Wallet>
#include <QApplication>
#include <QDebug>
int main(int argc, char **argv) {
QApplication app(argc, argv);
WId winId = 0; // Replace with actual window ID if needed
KWallet::Wallet *wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), winId, KWallet::Wallet::Synchronous);
if (wallet && wallet->isOpen()) {
if (!wallet->hasFolder("MyAppFolder")) {
wallet->createFolder("MyAppFolder");
}
wallet->setFolder("MyAppFolder");
wallet->writePassword("", "user", "password");
qDebug() << "Entry written successfully.";
wallet->deleteLater();
} else {
qDebug() << "Failed to open wallet.";
}
return app.exec();
}
This approach uses KWallet::Wallet::openWallet with the local wallet type, followed by writePassword for simple string storage. Asynchronous mode can be enabled by passing KWallet::Wallet::Asynchronous as the last parameter to handle wallet unlocking via Qt signals.[19]
For Python developers, KWallet is accessible via its D-Bus interface using the dbus-python library, enabling cross-language integration without KDE-specific dependencies. Connect to the session bus, obtain a proxy to the org.kde.KWallet service at /modules/kwalletd, and invoke methods like writePassword with error handling for wallet states. The following script opens the wallet asynchronously and stores a password:
python
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import [gobject](/page/GObject)
DBusGMainLoop(set_as_default=True)
bus = [dbus](/page/D-Bus).SessionBus()
try:
proxy = bus.get_object('org.kde.KWallet', '/modules/kwalletd')
interface = [dbus](/page/D-Bus).Interface(proxy, 'org.kde.KWallet')
handle = interface.openAsync('kdewallet', 0, 'MyApp', False)
if handle > 0:
status = interface.writePassword(handle, 'MyAppFolder', 'user', 'password', 'MyApp')
if status == 0:
[print](/page/Print)("Password written successfully.")
else:
[print](/page/Print)(f"Write failed with status: {status}")
else:
[print](/page/Print)("Failed to open wallet.")
except dbus.DBusException as e:
[print](/page/Print)(f"D-Bus error: {e}")
[gobject](/page/GObject).MainLoop().run()
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import [gobject](/page/GObject)
DBusGMainLoop(set_as_default=True)
bus = [dbus](/page/D-Bus).SessionBus()
try:
proxy = bus.get_object('org.kde.KWallet', '/modules/kwalletd')
interface = [dbus](/page/D-Bus).Interface(proxy, 'org.kde.KWallet')
handle = interface.openAsync('kdewallet', 0, 'MyApp', False)
if handle > 0:
status = interface.writePassword(handle, 'MyAppFolder', 'user', 'password', 'MyApp')
if status == 0:
[print](/page/Print)("Password written successfully.")
else:
[print](/page/Print)(f"Write failed with status: {status}")
else:
[print](/page/Print)("Failed to open wallet.")
except dbus.DBusException as e:
[print](/page/Print)(f"D-Bus error: {e}")
[gobject](/page/GObject).MainLoop().run()
This example handles the asynchronous open via openAsync (returning a handle), then uses writePassword with folder, key, value, and app ID parameters; errors are caught via D-Bus exceptions for robustness.[63]
Common scenarios include storing API keys in custom folders for application-specific isolation and querying existing entries with user prompts as fallbacks. For instance, before writing an API key, check entryList for the key in a "APIKeys" folder; if absent, prompt the user and use writePassword. This organizes credentials hierarchically while providing graceful degradation if the wallet is locked.[63]
In testing, developers can mock the KWallet interface using Qt's mock objects or D-Bus test proxies to simulate wallet operations without a real backend, ensuring unit tests remain isolated. For integration tests, connect to Qt signals like walletOpened for asynchronous unlock verification, confirming entries are accessible post-unlock.[19]
As of 2025, KWallet supports a Secret Service proxy for broader compatibility, allowing developers to use the standard org.freedesktop.secrets D-Bus API instead of the legacy interface. An updated example involves creating items via CreateItem on the collection proxy, such as storing a password in a KDE-compatible service:
python
import dbus
from secretstorage import dbussession, collection
dbus_session = dbussession.DBusSession()
collection = collection.get_default_collection(dbus_session)
if collection.is_locked():
collection.unlock()
item = collection.create_item("MyApp", {"user": "username"}, "password", replace=True)
print("Item created via Secret Service proxy.")
import dbus
from secretstorage import dbussession, collection
dbus_session = dbussession.DBusSession()
collection = collection.get_default_collection(dbus_session)
if collection.is_locked():
collection.unlock()
item = collection.create_item("MyApp", {"user": "username"}, "password", replace=True)
print("Item created via Secret Service proxy.")
This leverages libraries like secretstorage for the org.freedesktop.secrets.CreateItem method, proxying through KWallet's backend for seamless KDE integration.[7]