Bug 984780 (CVE-2016-4444) - VUL-0: CVE-2016-4444: setroubleshoot: Multiple issues found during audits
Summary: VUL-0: CVE-2016-4444: setroubleshoot: Multiple issues found during audits
Status: RESOLVED INVALID
Alias: CVE-2016-4444
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Johannes Segitz
QA Contact: Security Team bot
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 983452
  Show dependency treegraph
 
Reported: 2016-06-15 08:08 UTC by Marcus Meissner
Modified: 2017-05-15 07:47 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Meissner 2016-06-15 08:08:33 UTC
+++ This bug was initially created as a clone of Bug #983452 +++

posted by sek on distros:



Hi

Due to a review request, it was necessary to have a look at setroubleshoot
again.

setroubleshoot (still) contains various code injection vulns, leading to
full (unconfined) root.
PoC has been tested on CentOS 6.6, 6.8 and 7. PoC as well works inside
Docker containers to achieve running in a setroubleshoot domain with
uid 0 on "the host". (PoC most likely also works on RHEL 6.x and 7 if
CentOS maps to it).
This is not CVE-2015-1815 and PoC runs on systems that are patched against it.

Here are the details:


1)

This bug is mitigated since setroubleshoot that is found on RHEL 7.2,
by running it as a dedicated user (untested).

Shell injection issue in setroubleshoot/audit_data.py:

def _set_tpath(self):
[...]
        if path.startswith("/") == False and inodestr:
                import subprocess
                command = "locate -b '\%s'" % path
                try:
                    output = subprocess.check_output(command,
                                                     stderr=subprocess.STDOUT,
                                                     shell=True)
[...]


taking 'path' off AVC denial messages and constructing a command thats
passed to "sh -c".  o.O
Note that AVC denial messages appear outside of containers, so
a setroubleshoot is usually run on the host, processing AVC messages
from containers. This allows for an easy breakout.

2)

I did not test this, but even though the run_fix() function in
SetroubleshootFixit.py is protected by auth_admin polkit rules, it looks
like theres good chance to pass XML documents via setroubleshoots
RPC/DBUS API that contains evil local_id or analysis_id fields and trick
real admins to "fix" AVC denials that inject code:

[...]
    def run_fix(self, local_id, analysis_id):
         import commands
         command = "sealert -f %s -P %s" % ( local_id, analysis_id)
         return commands.getoutput(command)
[...]

This is not mitigated by the run-as-user, since SetroubleshootFixit.py
still runs as root (and probably needs to).


There are various other occurences of subprocess calls for "rpm" and others,
which have already been mentioned in the CVE-2015-1815 report but probably
still unfixed because of "missing PoC".

The codebase is huge, and I wonder what kind of lax handling and
user-surfacing code inside critical SELinux components this is, in particular
where SELinux' aim is to harden the system.
Comment 2 Swamp Workflow Management 2016-06-15 22:00:39 UTC
bugbot adjusting priority
Comment 4 Marcus Meissner 2016-06-21 12:02:47 UTC
On Tue, 21 Jun 2016 11:45:01 +0200 Sebastian Krahmer wrote:

> 1)
> 
> This bug is mitigated since setroubleshoot that is found on RHEL 7.2,
> by running it as a dedicated user (untested).
> 
> Shell injection issue in setroubleshoot/audit_data.py:
> 
> def _set_tpath(self):
> [...]
>       if path.startswith("/") == False and inodestr:
>               import subprocess
>               command = "locate -b '\%s'" % path
>               try:
>                   output = subprocess.check_output(command,
>                                                    stderr=subprocess.STDOUT,
>                                                      shell=True)
> [...]
> 
> 
> taking 'path' off AVC denial messages and constructing a command thats
> passed to "sh -c".  o.O
> Note that AVC denial messages appear outside of containers, so
> a setroubleshoot is usually run on the host, processing AVC messages
> from containers. This allows for an easy breakout.
> 
> 
> 2)
> 
> I did not test this, but even though the run_fix() function in
> SetroubleshootFixit.py is protected by auth_admin polkit rules, it looks
> like theres good chance to pass XML documents via setroubleshoots
> RPC/DBUS API that contains evil local_id or analysis_id fields and trick
> real admins to "fix" AVC denials that inject code:
> 
> [...]
>     def run_fix(self, local_id, analysis_id):
>          import commands
>          command = "sealert -f %s -P %s" % ( local_id, analysis_id)
>          return commands.getoutput(command)
> [...]
> 
> This is not mitigated by the run-as-user, since SetroubleshootFixit.py
> still runs as root (and probably needs to).

CVE-2016-4989 was assigned to the issues above.

There are additional similar problems in setroubleshoot and
setroubleshoot-plugins:

- CVE-2016-4445, setroubleshoot, affecting 'sealert --fix'.  Problem was
  already fixed in version 3.2.23.

  https://github.com/fedora-selinux/setroubleshoot/commit/2d12677629ca319310f6263688bb1b7f676c01b7

- CVE-2016-4444, setroubleshoot-plugins, allow_execmod plugin.  Also
  previously fixed in versoin 3.2.23.

  https://github.com/fedora-selinux/setroubleshoot/commit/5cd60033ea7f5bdf8c19c27b23ea2d773d9b09f5

- CVE-2016-4446, setroubleshoot-plugins, allow_execstack plugin.
  Similar to the previous one, only using commands.getoutput instead of
  commands.getstatusoutput.

  https://github.com/fedora-selinux/setroubleshoot/blob/setroubleshoot-plugins-3.3.4/plugins/src/allow_execstack.py#L29

-- 
Tomas Hoger / Red Hat Product Security
Comment 5 Sebastian Krahmer 2017-05-15 07:47:30 UTC
When I recall correctly, setroubleshoot wasnt making it
onto distro. So closing. Needs to be closed to
solve dependency for bsc#983452 so that can be closed
either.