SearchItems returns no locked items, so libsecret never prompts to unlock

オープン
#614 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

Start with search_inner_items in server/src/collection/mod.rs and trace how SearchItems handles a locked keyring and attribute matching. The issue explains why returning every locked item can expose the wrong secret, so investigate how matching could work while locked. Done means a lookup prompts to unlock the matching item and returns its secret without returning unrelated items; the reproduction uses secret-tool and busctl.

索引モデルが issue の本文から書いたものです。

説明

question server

When the login collection is locked, SearchItems returns both arrays empty, including the locked array. libsecret's secret_password_lookup unlocks an item only when the search reports it in locked. With both arrays empty, it concludes that no matching secret exists. The application is told the secret doesn't exist, with no unlock prompt and no error.

Environment
  • oo7 main at 901e7406 ("python: stop shipping stray type stub files"), plus one unrelated patch that retries the daemon's connect to the login helper at startup
  • libsecret 0.21.8, with secret-tool as the client
  • oo7-daemon as the only Secret Service provider, on a private session bus with an empty XDG_DATA_HOME. The login collection was unlocked at startup through oo7-daemon-login.
Steps to reproduce
$ C=/org/freedesktop/secrets/collection/login
$ echo -n topsecret | secret-tool store --label=test service demo key demo
$ secret-tool lookup service demo key demo
topsecret
$ busctl --user call org.freedesktop.secrets /org/freedesktop/secrets \
    org.freedesktop.Secret.Service SearchItems "a{ss}" 2 service demo key demo
aoao 1 "/org/freedesktop/secrets/collection/login/1" 0

$ secret-tool lock --collection=$C
$ busctl --user get-property org.freedesktop.secrets $C \
    org.freedesktop.Secret.Collection Locked
b true
$ busctl --user call org.freedesktop.secrets /org/freedesktop/secrets \
    org.freedesktop.Secret.Service SearchItems "a{ss}" 2 service demo key demo
aoao 0 0
$ secret-tool lookup service demo key demo; echo "rc=$?"
rc=1

The final lookup returns in about 40 ms. No prompt appears and nothing is printed.

The item is still there:

$ busctl --user get-property org.freedesktop.secrets $C org.freedesktop.Secret.Collection Items
ao 1 "/org/freedesktop/secrets/collection/login/1"
$ busctl --user get-property org.freedesktop.secrets $C/1 org.freedesktop.Secret.Item Locked
b true
Expected

SearchItems returns aoao 0 1 "/org/freedesktop/secrets/collection/login/1". libsecret then calls Unlock on that path, the prompter asks for the password, and the lookup returns the secret.

Cause

search_inner_items in server/src/collection/mod.rs returns early while the keyring is locked:

if keyring.is_locked() {
    return Ok(Vec::new());
}

The stored attribute hashes are MACs keyed with the keyring key, so a locked keyring can't match attributes at all.

Returning every locked item is not a safe fix

It might look as if SearchItems could return all of the collection's items in locked without matching them. libsecret doesn't search again after unlocking, though. on_lookup_searched in libsecret/secret-methods.c unlocks only locked[0], and on_lookup_unlocked then returns the secret of whatever item that was:

} else if (locked && locked[0]) {
        const gchar *paths[] = { locked[0], NULL };
        secret_service_unlock_dbus_paths (self, paths, cancellable,
                                          on_lookup_unlocked, ...);

With unmatched candidates in locked, a lookup would hand an application some other item's secret. Fixing this needs a way to match attributes while the keyring is locked.

Impact
  • Only reads are affected. secret-tool store into a locked collection prompts and works, because writing needs the collection open. A prompter can therefore look healthy while every lookup fails without a sound.
  • An application told that no secret exists may decide nothing was ever stored and write a fresh credential over the old one.
  • This hits whenever the login collection ends up locked during a session: after a daemon restart, an explicit lock, or a login where no password reaches pam_oo7 (for example a FIDO2 login).

I found this with AI assistance (Claude Opus 5.5) while testing oo7 as a gnome-keyring replacement. The reproduction above was run on the oo7 commit listed under Environment.

主要言語
Rust
スター
481
フォーク
62
平均マージ
9時間 51分
マージ済み PR(30日)
55

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

linux-credentials/oo7 のほかの issue

linux-credentials/oo7 の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。