sssd: a negative sudoUser entry clears a grant it did not match
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Leggi le righe 186–230 di plugins/sudoers/sssd.c, in particolare il controllo delle voci negative alla riga 226, e confronta la gestione di match per ogni voce nelle righe 318–347 di plugins/sudoers/ldap.c. Riproduci il caso indicato sudoUser: alice, !bob con una build abilitata per SSSD e controlla il risultato di sudo -l; il lavoro è concluso quando una voce negativa non corrispondente non revoca più l’autorizzazione di Alice, mentre le voci negative corrispondenti continuano a rifiutare l’utente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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;
}
}
- Lingua principale
- C
- Stelle
- 1.7k
- Fork
- 306
- Merge medio
- 1g 2h
- PR unite (30g)
- 22
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sudo-project/sudo
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
sudo-project/sudo#583 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
sudo-project/sudo#581 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Signal forwarded to the command is lost when it arrives between fork() and execve() of the commandAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
sudo-project/sudo#566 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
sudo-project/sudo#553 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
sudo-project/sudo#552 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sudo-project/sudo
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
libsdl-org/SDL#16607 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
PowerShell/Win32-OpenSSH#2482 · 1 reazione ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
OpenMathLib/OpenBLAS#6192 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 2 giorni