Blame SOURCES/00391-cve-2022-42919.patch

bbebd1
From 85178d5849a4d9b5b46e7b91b1ebad7425139b44 Mon Sep 17 00:00:00 2001
bbebd1
From: "Gregory P. Smith" <greg@krypto.org>
bbebd1
Date: Thu, 20 Oct 2022 15:30:09 -0700
bbebd1
Subject: [PATCH] gh-97514: Don't use Linux abstract sockets for
bbebd1
 multiprocessing (GH-98501)
bbebd1
bbebd1
Linux abstract sockets are insecure as they lack any form of filesystem
bbebd1
permissions so their use allows anyone on the system to inject code into
bbebd1
the process.
bbebd1
bbebd1
This removes the default preference for abstract sockets in
bbebd1
multiprocessing introduced in Python 3.9+ via
bbebd1
https://github.com/python/cpython/pull/18866 while fixing
bbebd1
https://github.com/python/cpython/issues/84031.
bbebd1
bbebd1
Explicit use of an abstract socket by a user now generates a
bbebd1
RuntimeWarning.  If we choose to keep this warning, it should be
bbebd1
backported to the 3.7 and 3.8 branches.
bbebd1
(cherry picked from commit 49f61068f49747164988ffc5a442d2a63874fc17)
bbebd1
bbebd1
Co-authored-by: Gregory P. Smith <greg@krypto.org>
bbebd1
---
bbebd1
 Lib/multiprocessing/connection.py                 |  5 -----
bbebd1
 .../2022-09-07-10-42-00.gh-issue-97514.Yggdsl.rst | 15 +++++++++++++++
bbebd1
 2 files changed, 15 insertions(+), 5 deletions(-)
bbebd1
 create mode 100644 Misc/NEWS.d/next/Security/2022-09-07-10-42-00.gh-issue-97514.Yggdsl.rst
bbebd1
bbebd1
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
bbebd1
index 510e4b5aba44..8e2facf92a94 100644
bbebd1
--- a/Lib/multiprocessing/connection.py
bbebd1
+++ b/Lib/multiprocessing/connection.py
bbebd1
@@ -73,11 +73,6 @@ def arbitrary_address(family):
bbebd1
     if family == 'AF_INET':
bbebd1
         return ('localhost', 0)
bbebd1
     elif family == 'AF_UNIX':
bbebd1
-        # Prefer abstract sockets if possible to avoid problems with the address
bbebd1
-        # size.  When coding portable applications, some implementations have
bbebd1
-        # sun_path as short as 92 bytes in the sockaddr_un struct.
bbebd1
-        if util.abstract_sockets_supported:
bbebd1
-            return f"\0listener-{os.getpid()}-{next(_mmap_counter)}"
bbebd1
         return tempfile.mktemp(prefix='listener-', dir=util.get_temp_dir())
bbebd1
     elif family == 'AF_PIPE':
bbebd1
         return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' %
bbebd1
diff --git a/Misc/NEWS.d/next/Security/2022-09-07-10-42-00.gh-issue-97514.Yggdsl.rst b/Misc/NEWS.d/next/Security/2022-09-07-10-42-00.gh-issue-97514.Yggdsl.rst
bbebd1
new file mode 100644
bbebd1
index 000000000000..02d95b570520
bbebd1
--- /dev/null
bbebd1
+++ b/Misc/NEWS.d/next/Security/2022-09-07-10-42-00.gh-issue-97514.Yggdsl.rst
bbebd1
@@ -0,0 +1,15 @@
bbebd1
+On Linux the :mod:`multiprocessing` module returns to using filesystem backed
bbebd1
+unix domain sockets for communication with the *forkserver* process instead of
bbebd1
+the Linux abstract socket namespace.  Only code that chooses to use the
bbebd1
+:ref:`"forkserver" start method <multiprocessing-start-methods>` is affected.
bbebd1
+
bbebd1
+Abstract sockets have no permissions and could allow any user on the system in
bbebd1
+the same `network namespace
bbebd1
+<https://man7.org/linux/man-pages/man7/network_namespaces.7.html>`_ (often the
bbebd1
+whole system) to inject code into the multiprocessing *forkserver* process.
bbebd1
+This was a potential privilege escalation. Filesystem based socket permissions
bbebd1
+restrict this to the *forkserver* process user as was the default in Python 3.8
bbebd1
+and earlier.
bbebd1
+
bbebd1
+This prevents Linux `CVE-2022-42919
bbebd1
+<https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-42919>`_.