Bug 1607282 (CVE-2018-4180)

Summary: CVE-2018-4180 cups: Local privilege escalation to root due to insecure environment variable handling
Product: [Other] Security Response Reporter: Andrej Nemec <anemec>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: bmcclain, dblechte, dfediuck, eedri, jpopelka, mgoldboi, michal.skrivanek, rschiron, sbonazzo, sherold, twaugh, zdohnal
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
It was discovered that CUPS allows non-root users to pass environment variables to CUPS backends. Affected backends use attacker-controlled environment variables without proper sanitization. A local attacker, who is part of one of the groups specified in the SystemGroups directive, could use the cupsctl binary to set SetEnv and PassEnv directives and potentially controls the flow of the affected backend, resulting in some cases in arbitrary code execution with root privileges.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 22:32:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1607293, 1607295, 1608720, 1608721, 1608722, 1608764    
Bug Blocks: 1607292    

Description Andrej Nemec 2018-07-23 08:05:15 UTC
Affected versions of CUPS allow for the SetEnv and PassEnv directives to be specified in the cupsd.conf file, which is editable by non-root users using the cupsctl binary.  This allows attacker-controlled environment variables to be passed to CUPS backends, some of which are run as root.  By passing malicious values in environment variables to affected backends, it is possible to execute an attacker-supplied binary as root, subject to sandbox restrictions.

References:

https://blog.gdssecurity.com/labs/2018/7/11/cups-local-privilege-escalation-and-sandbox-escapes.html

Upstream patch:

https://github.com/apple/cups/commit/d47f6aec436e0e9df6554436e391471097686ecc

Comment 1 Andrej Nemec 2018-07-23 08:30:39 UTC
Created cups tracking bugs for this issue:

Affects: fedora-all [bug 1607293]

Comment 6 Riccardo Schirone 2018-07-26 08:20:25 UTC
On Linux the sandbox feature is not enabled, however SELinux may restricts the allowed actions an attacker can accomplish. Moreover, on RHEL the SystemGroup defined in /etc/cups/cups-files.conf (or in /etc/cups/cupsd.conf in RHEL 5 and 6) only includes groups `sys` and `root`, thus reducing considerably the set of users who can run cupsctl and perform the attack.

Comment 7 Riccardo Schirone 2018-07-26 08:55:20 UTC
Decreasing the Impact of the flaw to Moderate, because of the high privileges required to exploit it.

Comment 8 Riccardo Schirone 2018-07-26 09:12:24 UTC
Mitigation:

Do not add untrusted users to sys and root groups.

Comment 10 Riccardo Schirone 2018-07-27 09:31:24 UTC
Though RHEL 5 still allows to set PassEnv and SetEnv through cupsctl even by non-root users, it does not have the dnssd backend which allows an attacker to supply a binary which is executed with root permissions. For this reason the impact on RHEL 5 is Low.

Comment 11 errata-xmlrpc 2020-03-31 19:16:08 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2020:1050 https://access.redhat.com/errata/RHSA-2020:1050

Comment 12 Product Security DevOps Team 2020-03-31 22:32:48 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2018-4180