Bug 1631420 (CVE-2018-1000802) - CVE-2018-1000802 python: Command injection in the shutil module
Summary: CVE-2018-1000802 python: Command injection in the shutil module
Alias: CVE-2018-1000802
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
Depends On: 1631421 1631662
Blocks: 1631422
TreeView+ depends on / blocked
Reported: 2018-09-20 14:32 UTC by Andrej Nemec
Modified: 2021-02-16 23:01 UTC (History)
19 users (show)

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.
Clone Of:
Last Closed: 2018-10-10 07:33:46 UTC

Attachments (Terms of Use)

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:


Upstream patch:


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

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.

Note You need to log in before you can comment on or make changes to this bug.