When a host is removed from a Sudo rule, and the host list is left empty, the user unexpectedly gains full sudo access to all hosts specified in the HBAC rule. This behavior is contrary to the expected outcome, where the user should have no sudo access since the host list is empty.
When the host list in a Sudo rule is empty, the user should not have sudo access to any servers. The current behavior, where the user gains full access to all hosts listed in the HBAC rule, is unexpected and poses a security risk.
The user receives full sudo access to all servers listed in the HBAC rule, even though the Sudo rule’s host list is empty.
Hi,
thank you for the report. Can you add the output of ipa sudorule-show --all -raw your_sudo_rule_name before and after removing the host?
ipa sudorule-show --all -raw your_sudo_rule_name
bye, Sumit
Before:
$ ipa sudorule-show --all --raw %team_foo_sudo dn: ipaUniqueID=97a37106-28e7-11eb-b46f-02420a203611,cn=sudorules,cn=sudo,dc=foo,dc=com cn: %team_foo_sudo description: Team Foo ipaenabledflag: TRUE cmdcategory: all ipasudoopt: !authenticate memberhost: fqdn=some-server.foo.com,cn=computers,cn=accounts,dc=foo,dc=com memberuser: cn=team_foo,cn=groups,cn=accounts,dc=foo,dc=com ipaUniqueID: 97a37106-28e7-11eb-b46f-02420a203611 objectClass: ipaassociation objectClass: ipasudorule
After:
$ ipa sudorule-show --all --raw %team_foo_sudo dn: ipaUniqueID=97a37106-28e7-11eb-b46f-02420a203611,cn=sudorules,cn=sudo,dc=foo,dc=com cn: %team_foo_sudo description: Team Foo ipaenabledflag: TRUE cmdcategory: all ipasudoopt: !authenticate memberuser: cn=team_foo,cn=groups,cn=accounts,dc=foo,dc=com ipaUniqueID: 97a37106-28e7-11eb-b46f-02420a203611 objectClass: ipaassociation objectClass: ipasudorule
I think it is a bug in IPA commands that a rule is left without either memberhost or hostcategory attributes. This is what we can fix here but it is hardly a security issue in itself as you have to have admin rights to modify SUDO rules.
memberhost
hostcategory
However, actual decision on the rule is made by SUDO, after SSSD downloads the rule and passes it to SUDO. So we have here a potentially incorrect rule (without either memberhost or hostcategory) and SSSD should probably reject (filter out) it.
I think a separate bug needs to be open for SSSD.
@abbra Nobody removed the host from sudo rule directly. We removed the host from the ipa system completely. We didn't think removing host from system will grant full access
@patryk4815 I understand. memberof plugin in 389-ds did remove the reference to removed LDAP object. There is nothing IPA management tools can do in that case but we can at least do checks in the management code.
memberof
The actual bug in this case is in SSSD code where it should make a defensive default ("no members in the rule and no hostcategory=all => rule does not apply"). A bug is needed for SSSD which should be created at https://github.com/SSSD/sssd/issues.
We still need to cover the case of ipa sudorule-remove-host to trigger hostcategory=all to be added. Or prevent removing the last host? And, perhaps, a healthcheck rule to find SUDO rules without hostcategory=all and without memberhosts.
ipa sudorule-remove-host
hostcategory=all
Maybe removing last host from sudorule should imply removing sudorule itself? And prevent creating empty sudorule without specifying hosts (checkbox hostcategory false)
feel free to open a ticket for SSSD at https://github.com/SSSD/sssd/issues. So far I was not able to reproduce the issue and when SSSD is reading the sudo rules from LDAP there is a search filter which should filter out rules which neither have memberhost nor hostcategory set.
If possible, please add SSSD debug logs with debug_level = 9 in the [domain/...] and [sudo] sections of sssd.conf from a host which it not deleted. Ideally the logs should cover the state when the to be removed hosts is still present and sudo if failing and the state after the removal when sudo starts working on the unexpected host.
debug_level = 9
Thanks.