Skip to content

feat(import): read KeePass .kdbx databases, Passbolt's exports included - #371

Draft
cartudev wants to merge 1 commit into
anomalyco:devfrom
cartudev:feat/keepass-import
Draft

cartudev wants to merge 1 commit into
anomalyco:devfrom
cartudev:feat/keepass-import

Conversation

@cartudev

@cartudev cartudev commented Dec 3, 2026

Copy link
Copy Markdown

Adds deadbolt import database.kdbx (Passbolt's export included).

The CLI detects the KDBX signature and sends Command::ImportKeepass with the
file's path, the database's own passphrase (DEADBOLT_KDBX_PASSPHRASE, or
asked on a terminal) and --key-file when it needs one. The daemon opens the
file with keepass-rs and maps it beside the other exports:

  • an entry becomes a login; a group becomes a tag (Work/AWS), the root group
    is the database's name and is not a tag
  • TimeOtp-Secret-Base32 with TimeOtp-Algorithm/-Length/-Period becomes
    the otp field as an otpauth:// URI (KeePassXC's otp field is used as it
    is); a value deadbolt cannot read is kept as an extra field, counted
  • other custom fields are kept (secret when the database protected them)
  • attachments are counted and left out for now; the recycle bin is skipped
  • DAEMON_PROTOCOL_VERSION goes to 39

Why the daemon opens the file: the other imports send text because their
containers are a zip, JSON or CSV. A .kdbx is a typed database, and the
passphrase already crosses the socket for unlock. Opening it in the daemon
keeps the mapping where every other export's mapping lives, and keeps binary
out of the wire.

Tested against a real Passbolt export (KDBX 3.1, AES-KDF, 329 entries, 31 TOTP):

dry run:  would import 321 from KeePass (logins 321, cards 0)
          skipped 8 duplicates
          warning: 2 URLs that are not absolute URLs kept as text
import:   imported 321 from KeePass
re-import: imported 0, skipped 329 duplicates

The 8 are duplicates by the vault's existing key rule (a login's URL host,
name, username and password), not by the mapper.

cargo test -p deadbolt-cli import::keepass (7 tests), clippy with
-D warnings on cli/proto/engine, and scripts/file-size.sh are clean.

Blocked on sseemayer/keepass-rs#406. keepass 0.18.5 panics on an empty
<ExpiryTime>, which Passbolt writes on every entry that never expires:

panicked at src/format/xml_db/timestamp.rs:78:
range end index 8 out of range for slice of length 0

#406 reads it as the epoch baseline. This is a draft until 0.18.6 is out: then
the dependency (keepass = "0.18.5") needs no change at all. I ran the whole
flow above with that fix applied.

`deadbolt import` detects a database by its KDBX signature and sends the
daemon its path with the database's own passphrase (DEADBOLT_KDBX_PASSPHRASE,
or asked on a terminal), plus --key-file when it needs one. keepass-rs opens
KDBX 3.1 (what Passbolt exports) and 4.x; the importer maps an entry to a
login, a group to a tag, TimeOtp-* fields to an otp field, other custom fields
to extra ones, counts and leaves out attachments, and skips the recycle bin.

The daemon opens the file, the way it receives every other export's text, and
the mapping runs beside theirs. The daemon protocol goes to 39 for the new
command.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant