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

Đang mở
#614 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
authentication, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
481
Fork
62
Merge trung bình
9 giờ 51 phút
Pull request đã merge (30 ngày)
55

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của linux-credentials/oo7

Tất cả issue của linux-credentials/oo7

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.