Skip to content

Commit eae692e

Browse files
[3.10] gh-97514: Don't use Linux abstract sockets for multiprocessing (GH-98501) (GH-98503)
Linux abstract sockets are insecure as they lack any form of filesystem permissions so their use allows anyone on the system to inject code into the process. This removes the default preference for abstract sockets in multiprocessing introduced in Python 3.9+ via #18866 while fixing #84031. Explicit use of an abstract socket by a user now generates a RuntimeWarning. If we choose to keep this warning, it should be backported to the 3.7 and 3.8 branches. (cherry picked from commit 49f6106) Co-authored-by: Gregory P. Smith <greg@krypto.org> Automerge-Triggered-By: GH:gpshead
1 parent 0db4c59 commit eae692e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Lib/multiprocessing/connection.py

-5
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ def arbitrary_address(family):
7373
if family == 'AF_INET':
7474
return ('localhost', 0)
7575
elif family == 'AF_UNIX':
76-
# Prefer abstract sockets if possible to avoid problems with the address
77-
# size. When coding portable applications, some implementations have
78-
# sun_path as short as 92 bytes in the sockaddr_un struct.
79-
if util.abstract_sockets_supported:
80-
return f"\0listener-{os.getpid()}-{next(_mmap_counter)}"
8176
return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir())
8277
elif family == 'AF_PIPE':
8378
return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' %
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
On Linux the :mod:`multiprocessing` module returns to using filesystem backed
2+
unix domain sockets for communication with the *forkserver* process instead of
3+
the Linux abstract socket namespace. Only code that chooses to use the
4+
:ref:`"forkserver" start method <multiprocessing-start-methods>` is affected.
5+
6+
Abstract sockets have no permissions and could allow any user on the system in
7+
the same `network namespace
8+
<https://man7.org/linux/man-pages/man7/network_namespaces.7.html>`_ (often the
9+
whole system) to inject code into the multiprocessing *forkserver* process.
10+
This was a potential privilege escalation. Filesystem based socket permissions
11+
restrict this to the *forkserver* process user as was the default in Python 3.8
12+
and earlier.
13+
14+
This prevents Linux `CVE-2022-42919
15+
<https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-42919>`_.

0 commit comments

Comments
 (0)