sssd: a negative sudoUser entry clears a grant it did not match
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Lee las líneas 186–230 de plugins/sudoers/sssd.c, especialmente la comprobación de entradas negativas en la línea 226, y compara el tratamiento de match por entrada en las líneas 318–347 de plugins/sudoers/ldap.c. Reproduce el caso indicado sudoUser: alice, !bob con una compilación con SSSD habilitado y comprueba el resultado de sudo -l; se considera terminado cuando una entrada negativa no coincidente deja de revocar la autorización de Alice, mientras que las entradas negativas coincidentes siguen rechazando al usuario.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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;
}
}
- Lenguaje dominante
- C
- Estrellas
- 1.7k
- Forks
- 306
- Merge medio
- 1 d 3 h
- PR fusionados (30 d)
- 21
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sudo-project/sudo
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
sudo-project/sudo#583 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
sudo-project/sudo#581 ·
Los mantenedores suelen responder en 1 día
-
Signal forwarded to the command is lost when it arrives between fork() and execve() of the commandAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
sudo-project/sudo#566 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
sudo-project/sudo#553 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
sudo-project/sudo#552 ·
Los mantenedores suelen responder en 1 día
Todos los issues de sudo-project/sudo
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
JustAResearcher/gpu-unlock-ada#110 ·
Los mantenedores suelen responder en 1 día
-
documentation hygiene
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días
-
docs, ffi, python: update stale "built-in rules" references and pipeline order in docstringsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día