Bug 1631420 (CVE-2018-1000802)

Summary: CVE-2018-1000802 python: Command injection in the shutil module
Product: [Other] Security Response Reporter: Andrej Nemec <anemec>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: adev88, bkabrda, cstratak, dmalcolm, hhorak, jeffrey.ness, jorton, kevin, mcyprian, mhroncok, pviktori, python-maint, rkuska, security-response-team, shcherbina.iryna, slawomir, TicoTimo, tomspur, torsava
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 the shutil module of python does not properly sanitize input when creating a zip file on Windows. An attacker could use this flaw to cause a denial of service or add unintended files to the generated archive.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-10 07:33:46 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: 1631421, 1631662    
Bug Blocks: 1631422    

Description Andrej Nemec 2018-09-20 14:32:08 UTC
A command injection vulnerability was found in the shutil module (make_archive function) of Python that can result in Denial of Service or Information leak.

Upstream issue:

https://bugs.python.org/issue34540

Upstream patch:

https://github.com/python/cpython/pull/8985/commits/add531a1e55b0a739b0f42582f1c9747e5649ace

Comment 1 Andrej Nemec 2018-09-20 14:33:00 UTC
Created python26 tracking bugs for this issue:

Affects: fedora-all [bug 1631421]

Comment 2 Miro Hrončok 2018-09-20 18:59:32 UTC
While python26 is not impacted, python2 actually is.

Here's a PR: https://src.fedoraproject.org/rpms/python2/pull-request/26

Comment 3 Andrej Nemec 2018-09-21 08:43:39 UTC
Created python2 tracking bugs for this issue:

Affects: fedora-all [bug 1631662]

Comment 4 Riccardo Schirone 2018-10-05 07:47:54 UTC
Hi Miro,

Why are you saying that python2 is affected on Fedora?
I'm asking because I wasn't able to reproduce this flaw on Linux and I believe it can be triggered on Windows only. Do you have more information on this?

Comment 5 Miro Hrončok 2018-10-09 13:00:57 UTC
Oh. I only meant that the code is in 2.7, I haven't checked that the flaw is actually usable or Python 2.7 on Linux vulnerable.

Comment 6 Riccardo Schirone 2018-10-10 07:33:46 UTC
This doesn't seem to be exploitable when os.name != 'nt' (Windows). The main problem is that quoting is done in distutils.py/spawn.py:_nt_quote_args and it just wraps arguments in `"`, without escaping previous existing `"`. Moreover, os.spawn in Windows uses CreateProcess underneath, which transforms the list of arguments in a single string, thus creating this flaw there. On linux, execv family functions are used and each argument is interpreted as a single filename, preventing this flaw.

Comment 8 Riccardo Schirone 2018-10-10 07:42:22 UTC
Statement:

This issue did not affect the versions of python as shipped with Red Hat Enterprise Linux 5, 6 and 7 as Linux does not use the vulnerable code.