Red Hat Bugzilla – Bug 886648
Access granted with invalid sudoRunAsUser/sudoRunAsGroup
Last modified: 2015-03-02 00:27:19 EST
Description of problem: Sudo still grants access when the matching sudo rule, accessed either with ldap or sssd sudoers plugin, has sudoRunAsUser or sudoRunAsGroup set to an invalid user or group ID in the form of #id#, e.g. #10002#. Version-Release number of selected component (if applicable): sssd-client-1.9.2-37.el6.x86_64 sssd-1.9.2-37.el6.x86_64 sudo-1.8.6p3-6.el6.x86_64 libsss_idmap-1.9.2-37.el6.x86_64 libsss_sudo-1.9.2-37.el6.x86_64 How reproducible: always Steps to Reproduce: 1. Create a sudo rule employing #id-format value in sudoRunAsUser or sudoRunAsGroup. 2. Verify that access is granted. 3. Append '#' character to the value. 4. Try getting access again. Actual results: access is granted Expected results: access is denied
This request was not resolved in time for the current release. Red Hat invites you to ask your support representative to propose this request, if still desired, for consideration in the next release of Red Hat Enterprise Linux.
Sudo accepts the invalid strings because it uses atoi() to convert the string to an uid/gid. I've changed the code to use strtol and added checks that the whole string was accepted by it.
Created attachment 784416 [details] proposed patch
Verified fixed with sudo-1.8.6p3-11.el6.x86_64. Relevant sudo suite output: :: [ PASS ] :: attrs_runasuser_user_id_invalid (Expected 0, got 0) :: [ PASS ] :: attrs_runasgroup_id_invalid (Expected 0, got 0)
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2013-1701.html