CVE-2018-1000117: Buffer overflow vulnerability in os.symlink on Windows
On February 27th, 2018, the Python Security Response team was notified
of a buffer overflow issue in the
os.symlink() method on Windows. The
issue affects all versions of Python between 3.2 and 3.6.4, including
the 3.7 beta releases. It has been patched for the next releases of 3.4,
3.5, 3.6 and 3.7.
Scripts may be vulnerable if they use
os.symlink() on Windows and an
attacker is able to influence the location where links are created. As
os.symlink requires additional privileges, exploits using this
vulnerability are more likely to result in escalation of privilege.
Besides applying the fix to CPython, scripts can also ensure that the
length of each path argument is less than 260, and if the source is a
relative path, that its combination with the destination is also shorter
than 260 characters. That is:
assert (len(src) < 260 and
len(dest) < 260 and
len(os.path.join(os.path.dirname(dest), src)) < 260)
Scripts that explicitly pass the target_is_directory argument as True
are not vulnerable. Scripts on Python 3.5 that use bytes for paths are
not vulnerable, because of a combination of stack layout and added
parameter validation, but will still not behave correctly for long paths.
This vulnerability has been registered as CVE-2018-1000117, and patched
in the commits listed below. This patch prevents the buffer overflow,
but does not raise any new errors or enable the use of long paths when
Many thanks to Alexey Izbyshev for the report, and helping us work
through developing the patch.
- Disclosure date: 2018-03-05 (Python issue bpo-33001 reported)
- Reported at: 2018-02-27 (email to the PSRT)
- Reported by: Alexey Izbyshev
- Python 2.7
- Python 3.4
- Python 3.5
Buffer overflow vulnerability in os.symlink on Windows (CVE-2018-1000117).
- Python issue: bpo-33001
- Creation date: 2018-03-05
- Reporter: Steve Dower
Python Software Foundation CPython version From 3.2 until 3.6.4 on Windows contains a Buffer Overflow vulnerability in os.symlink() function on Windows that can result in Arbitrary code execution, likely escalation of privilege. This attack appears to be exploitable via a python script that creates a symlink with an attacker controlled name or location. This vulnerability appears to have been fixed in 3.7.0 and 3.6.5.
Timeline using the disclosure date 2018-03-05 as reference:
- 2018-02-27 (-6 days): Reported (email to the PSRT)
- 2018-03-05: Python issue bpo-33001 reported by Steve Dower
- 2018-03-05 (+0 days): commit 96fdbac
- 2018-03-05 (+0 days): commit baa4507
- 2018-03-07 (+2 days): CVE-2018-1000117 published
- 2018-03-28 (+23 days): Python 3.6.5 released
- 2018-06-28: Python 3.7.0 released