Skip to content

sudo_ldap_check_non_unix_group: don't treat a group plugin error as a match - #582

Merged
millert merged 1 commit into
sudo-project:mainfrom
iefa-m:ldap-group-plugin-error
Oct 25, 2026
Merged

millert merged 1 commit into
sudo-project:mainfrom
iefa-m:ldap-group-plugin-error

Conversation

@iefa-m

@iefa-m iefa-m commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

sudo_ldap_check_non_unix_group() grants an LDAP sudoUser value of the form %:group whenever group_plugin_query() returns non-zero. group_plugin_query() passes the plugin's query() result through unchanged, and the Python group plugin returns SUDO_RC_ERROR (-1) when its lookup raises, so a sudoRole with sudoUser: %:admins is granted to a user whose group lookup failed. The same rule in a sudoers file is denied, because usergr_matches() in match.c requires == true.

Compare the result against true, matching match.c. This is the only caller that tests the result for non-zero, and keeping the check here means a plugin error fails closed for LDAP rules the same way it already does for sudoers rules.

… match

group_plugin_query() returns the plugin's query() result unchanged,
and a group plugin may return a negative value on error (the Python
group plugin returns SUDO_RC_ERROR when the lookup raises). The LDAP
%:group check tested the result for non-zero, so a failed lookup
granted the sudoRole. Compare against true, as usergr_matches() does
for the same rule in a sudoers file.

@millert millert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@millert
millert merged commit 23629ae into sudo-project:main Oct 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants