Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1848229

Summary: ipa sudorule allows deny commands with usercat=all
Product: Red Hat Enterprise Linux 7 Reporter: xifan
Component: ipaAssignee: Florence Blanc-Renaud <frenaud>
Status: CLOSED DEFERRED QA Contact: ipa-qe <ipa-qe>
Severity: low Docs Contact:
Priority: low    
Version: 7.6CC: pcech, rcritten, tscherf
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-19 07:54:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Comment 2 Rob Crittenden 2020-06-24 15:13:35 UTC
Public description:

After adding deny commands into sudo rule, 'Command category' still shows all.

Reproducer:

# kinit admin
# ipa sudocmd-add '/bin/sh'
# ipa sudorule-add --hostcat='all' --usercat='all' --cmdcat='all' --order='7' deny_sudo_-s
# ipa sudorule-add-deny-command --sudocmds='/bin/sh' deny_sudo_-s
# ipa sudorule-show deny_sudo_-s --all

This is easily reproducible using the above steps. Adding deny rules/setting usercat=all should raise a mutually exclusive error.

Comment 3 Rob Crittenden 2020-06-24 15:17:10 UTC
Upstream ticket:
https://pagure.io/freeipa/issue/8382

Comment 4 Florence Blanc-Renaud 2020-07-10 10:33:58 UTC
RHEL-7.9 is already past the end of a Development Phase and development is being wrapped up. This bug is being moved to RHEL 7.9 z-stream.

Comment 6 Florence Blanc-Renaud 2021-02-05 16:54:33 UTC
I would be in favor of closing this as not a bug.

The sudoers man page, especially the SECURITY NOTES section, details the differences between
ALL = ALL, !<deny command>
and
ALL = !<deny command>
in the /etc/sudoers file.

----- 8< -----
   Limitations of the ‘!’ operator
     It is generally not effective to “subtract” commands from ALL using the
     ‘!’ operator.  A user can trivially circumvent this by copying the
     desired command to a different name and then executing that.  For exam‐
     ple:

     bill    ALL = ALL, !SU, !SHELLS

     Doesn't really prevent bill from running the commands listed in SU or
     SHELLS since he can simply copy those commands to a different name, or
     use a shell escape from an editor or other program.  Therefore, these
     kind of restrictions should be considered advisory at best (and rein‐
     forced by policy).

     In general, if a user has sudo ALL there is nothing to prevent them from
     creating their own program that gives them a root shell (or making their
     own copy of a shell) regardless of any ‘!’ elements in the user specifi‐
     cation.
----- >8 -----

but both are supported.

With cmdcat=all and a sudo-deny-command, the behavior is equivalent to ALL, !<deny cmd>:

$ ipa sudorule-show mysudorule
  Rule name: mysudorule
  Enabled: TRUE
  Host category: all
  Command category: all
  RunAs User category: all
  RunAs Group category: all
  Users: idmuser
  Sudo Deny Commands: cat

$ sudo -l
[...]
User idmuser may run the following commands on server:
    (ALL : ALL) ALL, !cat
                ^^^^^^^^^

while with cmdcat not specified and sudo-deny-command, the behavior is equivalent to !<deny cmd>:

$ ipa sudorule-show mysudorule
  Rule name: mysudorule
  Enabled: TRUE
  Host category: all
  RunAs User category: all
  RunAs Group category: all
  Users: idmuser
  Sudo Deny Commands: cat

$ sudo -l
[...]
User idmuser may run the following commands on server:
    (ALL : ALL) !cat
                ^^^^

Moreover, the code in ipa was intentionally modified to allow this type of config, please see commit https://pagure.io/freeipa/c/af2eb4d69506b641504d076e79b80c7ee54eeda9 related to issue https://pagure.io/freeipa/issue/4340

Comment 8 Petr Čech 2021-02-19 07:54:43 UTC
Red Hat Enterprise Linux 7 is in Maintenance Support 2 Phase. This bug was reevaluated and will be closed as it doesn’t meet the Maintenance Support 2 phase criteria, specifically: “Critical and Important impact Security Advisories (RHSAs) and selected (at Red Hat discretion) Urgent Priority Bug Fix Advisories (RHBAs)"
Thank you for understanding.
Red Hat Enterprise Linux Identity Management Team