sssd: a negative sudoUser entry clears a grant it did not match
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Đọc các dòng 186–230 trong plugins/sudoers/sssd.c, đặc biệt là bước kiểm tra mục phủ định ở dòng 226, rồi so sánh cách xử lý match cho từng mục trong các dòng 318–347 của plugins/sudoers/ldap.c. Tái hiện trường hợp được nêu sudoUser: alice, !bob với bản dựng bật SSSD và kiểm tra kết quả của sudo -l; hoàn thành khi một mục phủ định không khớp không còn xóa quyền của Alice, trong khi các mục phủ định khớp vẫn từ chối người dùng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
sudo_sss_check_user() walks the sudoUser list and maintains a single boolean that it treats as "this entry matched" at the point where negative entries are evaluated. The boolean is not per-entry: it is set by any positive match and never reset for the following entries. A rule such as alice, !bob therefore rejects alice, because the unmatched !bob entry is evaluated against the grant that alice had already produced.
Affected code: plugins/sudoers/sssd.c:186–230, specifically the negative-entry test at line 226. Unchanged in current master 3595b1527db3122616dea2568e0c5f86a328f8eb.
Reachable rejection sequence
- sudo is built
--with-sssdandnsswitch.confcontainssudoers: files sss. - A sudoRole carries
sudoUser: alice, !bob, and the role grants at least one command. alicerunssudo -l.sudoers_lookup()reachessudo_nss_sss.query(), which parses the role and callssudo_sss_check_user().- The first entry matches
alice, soretbecomes true at line 210 and the loop continues because the entry is notSPECIFIED(user_matched). - The second entry is negative and does not match
alice. Line 226 testsret && negated—retis still true from step 4 — so the grant is cleared and the loop breaks. - The role is discarded.
sudo -lreports that alice is not allowed to run sudo.
Reordering the list to !bob, alice restores the intended result, which shows the outcome depends on list order rather than on membership.
The direction is fail-closed: the affected user loses privileges they were granted, and no user gains privileges they were not. It requires a role whose positive entries precede an unrelated negative entry, so a role using only positive entries, or only negative ones, is unaffected. plugins/sudoers/ldap.c:318–347 performs the same evaluation with a per-entry match variable and does not have this behaviour.
This commit range is relevant: 00c60751 ("Fix evaluation of negative entries in sudoUser", 2026-01-25) removed !ret from the loop condition at line 190 but did not introduce a per-entry flag, so before that commit the negative entries were never evaluated at all and after it they are evaluated against the wrong state.
Suggested fix
Track whether the current entry matched, locally, and use that for the negative test. The rest of the loop can keep using the cumulative flag for its existing purposes.
for (i = 0; val_array[i] != NULL; ++i) {
bool matched = false;
...
if (/* this entry matches */) {
matched = true;
ret = true;
...
}
if (matched && negated) { /* was: if (ret && negated) */
ret = false;
break;
}
}
- Ngôn ngữ chính
- C
- Star
- 1.7k
- Fork
- 306
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 21
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sudo-project/sudo
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
sudo-project/sudo#583 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
sudo-project/sudo#581 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Signal forwarded to the command is lost when it arrives between fork() and execve() of the commandĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
sudo-project/sudo#566 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
sudo-project/sudo#553 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
sudo-project/sudo#552 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của sudo-project/sudo
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
JustAResearcher/gpu-unlock-ada#110 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation hygiene
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Documenting top-level assertionsĐang mởdocumentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày