Skip to content

fix(masterkey): resolve Linux v11 keys via Secret Service - #705

Merged
moonD4rk merged 4 commits into
mainfrom
fix/linux-secret-service-lookup
Nov 19, 2026
Merged

moonD4rk merged 4 commits into
mainfrom
fix/linux-secret-service-lookup

Conversation

@moonD4rk

@moonD4rk moonD4rk commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Fixes Linux v11 master-key retrieval on GNOME and KDE. Refs #572, #161 (not fully resolved here — see note).

Stacked on #704 (base feat/firefox-primary-password); GitHub retargets to main as the stack merges.

Problem

The Secret Service lookup enumerated a collection's items and matched the label exactly:

  • GNOME: a login keyring that lists stale item paths (7 of 10 here) makes a whole-collection read abort, so the live key is never reached — v11 reads "not found" even while unlocked.
  • KDE: KWallet exposes entries over Secret Service as <X> Keys/<X> Safe Storage, so an exact match misses them.

Fix

Rewrite dbusRetriever on godbus directly and drop the go-dbus-keyring dependency:

  • SearchItems by libsecret's schema (GNOME), KWallet's schema, and KWallet's user attribute (the entry name), so the lookup does not depend on the schema label KWallet sets.
  • Match the label exactly or by /-suffix, reading items one by one so a stale path is skipped.
  • Unlock only what opens without a prompt; a match hidden behind a locked keyring or closed wallet reports keyring or wallet is locked instead of not found.
  • Own a private session-bus connection bound to a timeout: connecting and every call are bounded, a lookup that runs out of time says so instead of not found, and a host without a session bus gets an error instead of a dbus-launched daemon left running.

Validated on real desktops (seeded fake data, author's VM, wallet open)

  • GNOME: v11 recovered for all 6 vaults; 34 cookies / 2 passwords all ok.
  • KDE: v11 recovered via the suffix match; 18 cookies all ok.

The follow-ups (locked error, user query, bounded calls, private connection) are not yet re-run on the VM. In a Linux container against a real gnome-keyring, the final code and the previous head agree on found (libsecret and KWallet-style labels), not found, and locked; without a session bus the old code launched a dbus-daemon and reported not found, the new one reports the missing bus.

Follow-ups

#161's environment (Ubuntu 22.04 + kdewallet5) has no Secret Service at all, so it needs native KWallet over D-Bus (3b). Refs #572, #161 — kept open for that.

Test

go test ./... + linux masterkey tests + golangci-lint clean; go mod tidy kept go 1.20. The lookup policy has a table test against a fake Secret Service (KWallet labels, stale path, prompt-free unlock, wallet that stays locked, timeout); seven deliberate mutations of it each fail a case.

@moonD4rk
moonD4rk force-pushed the fix/linux-secret-service-lookup branch from f683048 to fd9f3b0 Compare November 18, 2026 09:23
@moonD4rk
moonD4rk added this pull request to stack #706 November 18, 2026 14:07
@moonD4rk
moonD4rk force-pushed the fix/linux-secret-service-lookup branch from 9c3ea04 to 778a09e Compare November 19, 2026 02:41
Copilot AI balanced review requested due to automatic review settings November 19, 2026 02:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@moonD4rk
moonD4rk force-pushed the fix/linux-secret-service-lookup branch from 16cc7e9 to 12ea323 Compare November 19, 2026 08:47
Base automatically changed from feat/firefox-primary-password to main November 19, 2026 08:51
Enumerating a collection and matching the label exactly missed keys:
a GNOME keyring listing stale item paths aborted the whole read, and
KWallet labels entries "<X> Keys/<X> Safe Storage". Use SearchItems
(live items only) and match the label by suffix.
A locked wallet now reports "locked" instead of "not found", every
D-Bus call (label read, session close) is bounded by the timeout, and
the lookup also searches by KWallet's user attribute so it no longer
depends on the xdg:schema label. The label match is a tested pure func.
dbus.SessionBus spawned a dbus-daemon when no bus was found and ignored the
lookup deadline; call errors also read as not found. The client is now a type
with Close, and the lookup policy is tested against a fake.
@moonD4rk
moonD4rk force-pushed the fix/linux-secret-service-lookup branch from 12ea323 to d5892cc Compare November 19, 2026 08:51
@moonD4rk
moonD4rk merged commit 066dd15 into main Nov 19, 2026
9 checks passed
@moonD4rk
moonD4rk deleted the fix/linux-secret-service-lookup branch November 19, 2026 08:53
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.

2 participants