Blame SOURCES/00382-cve-2015-20107.patch

2d2d72
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2d2d72
From: Petr Viktorin <encukou@gmail.com>
2d2d72
Date: Fri, 3 Jun 2022 11:43:35 +0200
2d2d72
Subject: [PATCH] 00382-cve-2015-20107.patch
2d2d72
2d2d72
00382 #
2d2d72
Make mailcap refuse to match unsafe filenames/types/params (GH-91993)
2d2d72
2d2d72
Upstream: https://github.com/python/cpython/issues/68966
2d2d72
2d2d72
Tracker bug: https://bugzilla.redhat.com/show_bug.cgi?id=2075390
2d2d72
2d2d72
Backported from python3.
2d2d72
---
2d2d72
 Doc/library/mailcap.rst                       |  12 +
2d2d72
 Lib/mailcap.py                                |  29 +-
2d2d72
 Lib/test/mailcap.txt                          |  39 +++
2d2d72
 Lib/test/test_mailcap.py                      | 259 ++++++++++++++++++
2d2d72
 ...2-04-27-18-25-30.gh-issue-68966.gjS8zs.rst |   4 +
2d2d72
 5 files changed, 341 insertions(+), 2 deletions(-)
2d2d72
 create mode 100644 Lib/test/mailcap.txt
2d2d72
 create mode 100644 Lib/test/test_mailcap.py
2d2d72
 create mode 100644 Misc/NEWS.d/next/Security/2022-04-27-18-25-30.gh-issue-68966.gjS8zs.rst
2d2d72
2d2d72
diff --git a/Doc/library/mailcap.rst b/Doc/library/mailcap.rst
2d2d72
index 750d085796f..5f75ee6086e 100644
2d2d72
--- a/Doc/library/mailcap.rst
2d2d72
+++ b/Doc/library/mailcap.rst
2d2d72
@@ -54,6 +54,18 @@ standard.  However, mailcap files are supported on most Unix systems.
2d2d72
    use) to determine whether or not the mailcap line applies.  :func:`findmatch`
2d2d72
    will automatically check such conditions and skip the entry if the check fails.
2d2d72
 
2d2d72
+   .. versionchanged:: 3.11
2d2d72
+
2d2d72
+      To prevent security issues with shell metacharacters (symbols that have
2d2d72
+      special effects in a shell command line), ``findmatch`` will refuse
2d2d72
+      to inject ASCII characters other than alphanumerics and ``@+=:,./-_``
2d2d72
+      into the returned command line.
2d2d72
+
2d2d72
+      If a disallowed character appears in *filename*, ``findmatch`` will always
2d2d72
+      return ``(None, None)`` as if no entry was found.
2d2d72
+      If such a character appears elsewhere (a value in *plist* or in *MIMEtype*),
2d2d72
+      ``findmatch`` will ignore all mailcap entries which use that value.
2d2d72
+      A :mod:`warning <warnings>` will be raised in either case.
2d2d72
 
2d2d72
 .. function:: getcaps()
2d2d72
 
2d2d72
diff --git a/Lib/mailcap.py b/Lib/mailcap.py
2d2d72
index 04077ba0db2..1108b447b1d 100644
2d2d72
--- a/Lib/mailcap.py
2d2d72
+++ b/Lib/mailcap.py
2d2d72
@@ -1,9 +1,18 @@
2d2d72
 """Mailcap file handling.  See RFC 1524."""
2d2d72
 
2d2d72
 import os
2d2d72
+import warnings
2d2d72
+import re
2d2d72
 
2d2d72
 __all__ = ["getcaps","findmatch"]
2d2d72
 
2d2d72
+
2d2d72
+_find_unsafe = re.compile(r'[^\xa1-\xff\w@+=:,./-]').search
2d2d72
+
2d2d72
+class UnsafeMailcapInput(Warning):
2d2d72
+    """Warning raised when refusing unsafe input"""
2d2d72
+
2d2d72
+
2d2d72
 # Part 1: top-level interface.
2d2d72
 
2d2d72
 def getcaps():
2d2d72
@@ -144,15 +153,22 @@ def findmatch(caps, MIMEtype, key='view', filename="/dev/null", plist=[]):
2d2d72
     entry to use.
2d2d72
 
2d2d72
     """
2d2d72
+    if _find_unsafe(filename):
2d2d72
+        msg = "Refusing to use mailcap with filename %r. Use a safe temporary filename." % (filename,)
2d2d72
+        warnings.warn(msg, UnsafeMailcapInput)
2d2d72
+        return None, None
2d2d72
     entries = lookup(caps, MIMEtype, key)
2d2d72
     # XXX This code should somehow check for the needsterminal flag.
2d2d72
     for e in entries:
2d2d72
         if 'test' in e:
2d2d72
             test = subst(e['test'], filename, plist)
2d2d72
+            if test is None:
2d2d72
+                continue
2d2d72
             if test and os.system(test) != 0:
2d2d72
                 continue
2d2d72
         command = subst(e[key], MIMEtype, filename, plist)
2d2d72
-        return command, e
2d2d72
+        if command is not None:
2d2d72
+            return command, e
2d2d72
     return None, None
2d2d72
 
2d2d72
 def lookup(caps, MIMEtype, key=None):
2d2d72
@@ -184,6 +200,10 @@ def subst(field, MIMEtype, filename, plist=[]):
2d2d72
             elif c == 's':
2d2d72
                 res = res + filename
2d2d72
             elif c == 't':
2d2d72
+                if _find_unsafe(MIMEtype):
2d2d72
+                    msg = "Refusing to substitute MIME type %r into a shell command." % (MIMEtype,)
2d2d72
+                    warnings.warn(msg, UnsafeMailcapInput)
2d2d72
+                    return None
2d2d72
                 res = res + MIMEtype
2d2d72
             elif c == '{':
2d2d72
                 start = i
2d2d72
@@ -191,7 +211,12 @@ def subst(field, MIMEtype, filename, plist=[]):
2d2d72
                     i = i+1
2d2d72
                 name = field[start:i]
2d2d72
                 i = i+1
2d2d72
-                res = res + findparam(name, plist)
2d2d72
+                param = findparam(name, plist)
2d2d72
+                if _find_unsafe(param):
2d2d72
+                    msg = "Refusing to substitute parameter %r (%s) into a shell command" % (param, name)
2d2d72
+                    warnings.warn(msg, UnsafeMailcapInput)
2d2d72
+                    return None
2d2d72
+                res = res + param
2d2d72
             # XXX To do:
2d2d72
             # %n == number of parts if type is multipart/*
2d2d72
             # %F == list of alternating type and filename for parts
2d2d72
diff --git a/Lib/test/mailcap.txt b/Lib/test/mailcap.txt
2d2d72
new file mode 100644
2d2d72
index 00000000000..08a76e65941
2d2d72
--- /dev/null
2d2d72
+++ b/Lib/test/mailcap.txt
2d2d72
@@ -0,0 +1,39 @@
2d2d72
+# Mailcap file for test_mailcap; based on RFC 1524
2d2d72
+# Referred to by test_mailcap.py
2d2d72
+
2d2d72
+#
2d2d72
+# This is a comment.
2d2d72
+#
2d2d72
+
2d2d72
+application/frame; showframe %s; print="cat %s | lp"
2d2d72
+application/postscript; ps-to-terminal %s;\
2d2d72
+    needsterminal
2d2d72
+application/postscript; ps-to-terminal %s; \
2d2d72
+    compose=idraw %s
2d2d72
+application/x-dvi; xdvi %s
2d2d72
+application/x-movie; movieplayer %s; compose=moviemaker %s; \
2d2d72
+       description="Movie"; \
2d2d72
+       x11-bitmap="/usr/lib/Zmail/bitmaps/movie.xbm"
2d2d72
+application/*; echo "This is \"%t\" but \
2d2d72
+       is 50 \% Greek to me" \; cat %s; copiousoutput
2d2d72
+
2d2d72
+audio/basic; showaudio %s; compose=audiocompose %s; edit=audiocompose %s;\
2d2d72
+description="An audio fragment"
2d2d72
+audio/* ; /usr/local/bin/showaudio %t
2d2d72
+
2d2d72
+image/rgb; display %s
2d2d72
+#image/gif; display %s
2d2d72
+image/x-xwindowdump; display %s
2d2d72
+
2d2d72
+# The continuation char shouldn't \
2d2d72
+# make a difference in a comment.
2d2d72
+
2d2d72
+message/external-body; showexternal %s %{access-type} %{name} %{site} \
2d2d72
+    %{directory} %{mode} %{server}; needsterminal; composetyped = extcompose %s; \
2d2d72
+    description="A reference to data stored in an external location"
2d2d72
+
2d2d72
+text/richtext; shownonascii iso-8859-8 -e richtext -p %s; test=test "`echo \
2d2d72
+    %{charset} | tr '[A-Z]' '[a-z]'`"  = iso-8859-8; copiousoutput
2d2d72
+
2d2d72
+video/*; animate %s
2d2d72
+video/mpeg; mpeg_play %s
2d2d72
\ No newline at end of file
2d2d72
diff --git a/Lib/test/test_mailcap.py b/Lib/test/test_mailcap.py
2d2d72
new file mode 100644
2d2d72
index 00000000000..35da7fb0741
2d2d72
--- /dev/null
2d2d72
+++ b/Lib/test/test_mailcap.py
2d2d72
@@ -0,0 +1,259 @@
2d2d72
+import copy
2d2d72
+import os
2d2d72
+import sys
2d2d72
+import test.support
2d2d72
+import unittest
2d2d72
+from test import support as os_helper
2d2d72
+from test import support as warnings_helper
2d2d72
+from collections import OrderedDict
2d2d72
+
2d2d72
+import mailcap
2d2d72
+
2d2d72
+
2d2d72
+# Location of mailcap file
2d2d72
+MAILCAPFILE = test.support.findfile("mailcap.txt")
2d2d72
+
2d2d72
+# Dict to act as mock mailcap entry for this test
2d2d72
+# The keys and values should match the contents of MAILCAPFILE
2d2d72
+
2d2d72
+MAILCAPDICT = {
2d2d72
+    'application/x-movie':
2d2d72
+        [{'compose': 'moviemaker %s',
2d2d72
+          'x11-bitmap': '"/usr/lib/Zmail/bitmaps/movie.xbm"',
2d2d72
+          'description': '"Movie"',
2d2d72
+          'view': 'movieplayer %s',
2d2d72
+          'lineno': 4}],
2d2d72
+    'application/*':
2d2d72
+        [{'copiousoutput': '',
2d2d72
+          'view': 'echo "This is \\"%t\\" but        is 50 \\% Greek to me" \\; cat %s',
2d2d72
+          'lineno': 5}],
2d2d72
+    'audio/basic':
2d2d72
+        [{'edit': 'audiocompose %s',
2d2d72
+          'compose': 'audiocompose %s',
2d2d72
+          'description': '"An audio fragment"',
2d2d72
+          'view': 'showaudio %s',
2d2d72
+          'lineno': 6}],
2d2d72
+    'video/mpeg':
2d2d72
+        [{'view': 'mpeg_play %s', 'lineno': 13}],
2d2d72
+    'application/postscript':
2d2d72
+        [{'needsterminal': '', 'view': 'ps-to-terminal %s', 'lineno': 1},
2d2d72
+         {'compose': 'idraw %s', 'view': 'ps-to-terminal %s', 'lineno': 2}],
2d2d72
+    'application/x-dvi':
2d2d72
+        [{'view': 'xdvi %s', 'lineno': 3}],
2d2d72
+    'message/external-body':
2d2d72
+        [{'composetyped': 'extcompose %s',
2d2d72
+          'description': '"A reference to data stored in an external location"',
2d2d72
+          'needsterminal': '',
2d2d72
+          'view': 'showexternal %s %{access-type} %{name} %{site}     %{directory} %{mode} %{server}',
2d2d72
+          'lineno': 10}],
2d2d72
+    'text/richtext':
2d2d72
+        [{'test': 'test "`echo     %{charset} | tr \'[A-Z]\' \'[a-z]\'`"  = iso-8859-8',
2d2d72
+          'copiousoutput': '',
2d2d72
+          'view': 'shownonascii iso-8859-8 -e richtext -p %s',
2d2d72
+          'lineno': 11}],
2d2d72
+    'image/x-xwindowdump':
2d2d72
+        [{'view': 'display %s', 'lineno': 9}],
2d2d72
+    'audio/*':
2d2d72
+        [{'view': '/usr/local/bin/showaudio %t', 'lineno': 7}],
2d2d72
+    'video/*':
2d2d72
+        [{'view': 'animate %s', 'lineno': 12}],
2d2d72
+    'application/frame':
2d2d72
+        [{'print': '"cat %s | lp"', 'view': 'showframe %s', 'lineno': 0}],
2d2d72
+    'image/rgb':
2d2d72
+        [{'view': 'display %s', 'lineno': 8}]
2d2d72
+}
2d2d72
+
2d2d72
+# In Python 2, mailcap doesn't return line numbers.
2d2d72
+# This test suite is copied from Python 3.11; for easier backporting we keep
2d2d72
+# data from there and remove the lineno.
2d2d72
+# So, for Python 2, MAILCAPDICT_DEPRECATED is the same as MAILCAPDICT
2d2d72
+MAILCAPDICT_DEPRECATED = MAILCAPDICT
2d2d72
+for entry_list in MAILCAPDICT_DEPRECATED.values():
2d2d72
+    for entry in entry_list:
2d2d72
+        entry.pop('lineno')
2d2d72
+
2d2d72
+
2d2d72
+class HelperFunctionTest(unittest.TestCase):
2d2d72
+
2d2d72
+    def test_listmailcapfiles(self):
2d2d72
+        # The return value for listmailcapfiles() will vary by system.
2d2d72
+        # So verify that listmailcapfiles() returns a list of strings that is of
2d2d72
+        # non-zero length.
2d2d72
+        mcfiles = mailcap.listmailcapfiles()
2d2d72
+        self.assertIsInstance(mcfiles, list)
2d2d72
+        for m in mcfiles:
2d2d72
+            self.assertIsInstance(m, str)
2d2d72
+        with os_helper.EnvironmentVarGuard() as env:
2d2d72
+            # According to RFC 1524, if MAILCAPS env variable exists, use that
2d2d72
+            # and only that.
2d2d72
+            if "MAILCAPS" in env:
2d2d72
+                env_mailcaps = env["MAILCAPS"].split(os.pathsep)
2d2d72
+            else:
2d2d72
+                env_mailcaps = ["/testdir1/.mailcap", "/testdir2/mailcap"]
2d2d72
+                env["MAILCAPS"] = os.pathsep.join(env_mailcaps)
2d2d72
+                mcfiles = mailcap.listmailcapfiles()
2d2d72
+        self.assertEqual(env_mailcaps, mcfiles)
2d2d72
+
2d2d72
+    def test_readmailcapfile(self):
2d2d72
+        # Test readmailcapfile() using test file. It should match MAILCAPDICT.
2d2d72
+        with open(MAILCAPFILE, 'r') as mcf:
2d2d72
+                d = mailcap.readmailcapfile(mcf)
2d2d72
+        self.assertDictEqual(d, MAILCAPDICT_DEPRECATED)
2d2d72
+
2d2d72
+    def test_lookup(self):
2d2d72
+        # Test without key
2d2d72
+
2d2d72
+        # In Python 2, 'video/mpeg' is tried before 'video/*'
2d2d72
+        # (unfixed bug: https://github.com/python/cpython/issues/59182 )
2d2d72
+        # So, these are in reverse order:
2d2d72
+        expected = [{'view': 'mpeg_play %s', },
2d2d72
+                    {'view': 'animate %s', }]
2d2d72
+        actual = mailcap.lookup(MAILCAPDICT, 'video/mpeg')
2d2d72
+        self.assertListEqual(expected, actual)
2d2d72
+
2d2d72
+        # Test with key
2d2d72
+        key = 'compose'
2d2d72
+        expected = [{'edit': 'audiocompose %s',
2d2d72
+                     'compose': 'audiocompose %s',
2d2d72
+                     'description': '"An audio fragment"',
2d2d72
+                     'view': 'showaudio %s',
2d2d72
+                     }]
2d2d72
+        actual = mailcap.lookup(MAILCAPDICT, 'audio/basic', key)
2d2d72
+        self.assertListEqual(expected, actual)
2d2d72
+
2d2d72
+        # Test on user-defined dicts without line numbers
2d2d72
+        expected = [{'view': 'mpeg_play %s'}, {'view': 'animate %s'}]
2d2d72
+        actual = mailcap.lookup(MAILCAPDICT_DEPRECATED, 'video/mpeg')
2d2d72
+        self.assertListEqual(expected, actual)
2d2d72
+
2d2d72
+    def test_subst(self):
2d2d72
+        plist = ['id=1', 'number=2', 'total=3']
2d2d72
+        # test case: ([field, MIMEtype, filename, plist=[]], <expected string>)
2d2d72
+        test_cases = [
2d2d72
+            (["", "audio/*", "foo.txt"], ""),
2d2d72
+            (["echo foo", "audio/*", "foo.txt"], "echo foo"),
2d2d72
+            (["echo %s", "audio/*", "foo.txt"], "echo foo.txt"),
2d2d72
+            (["echo %t", "audio/*", "foo.txt"], None),
2d2d72
+            (["echo %t", "audio/wav", "foo.txt"], "echo audio/wav"),
2d2d72
+            (["echo \\%t", "audio/*", "foo.txt"], "echo %t"),
2d2d72
+            (["echo foo", "audio/*", "foo.txt", plist], "echo foo"),
2d2d72
+            (["echo %{total}", "audio/*", "foo.txt", plist], "echo 3")
2d2d72
+        ]
2d2d72
+        for tc in test_cases:
2d2d72
+            self.assertEqual(mailcap.subst(*tc[0]), tc[1])
2d2d72
+
2d2d72
+class GetcapsTest(unittest.TestCase):
2d2d72
+
2d2d72
+    def test_mock_getcaps(self):
2d2d72
+        # Test mailcap.getcaps() using mock mailcap file in this dir.
2d2d72
+        # Temporarily override any existing system mailcap file by pointing the
2d2d72
+        # MAILCAPS environment variable to our mock file.
2d2d72
+        with os_helper.EnvironmentVarGuard() as env:
2d2d72
+            env["MAILCAPS"] = MAILCAPFILE
2d2d72
+            caps = mailcap.getcaps()
2d2d72
+            self.assertDictEqual(caps, MAILCAPDICT)
2d2d72
+
2d2d72
+    def test_system_mailcap(self):
2d2d72
+        # Test mailcap.getcaps() with mailcap file(s) on system, if any.
2d2d72
+        caps = mailcap.getcaps()
2d2d72
+        self.assertIsInstance(caps, dict)
2d2d72
+        mailcapfiles = mailcap.listmailcapfiles()
2d2d72
+        existingmcfiles = [mcf for mcf in mailcapfiles if os.path.exists(mcf)]
2d2d72
+        if existingmcfiles:
2d2d72
+            # At least 1 mailcap file exists, so test that.
2d2d72
+            for (k, v) in caps.items():
2d2d72
+                self.assertIsInstance(k, str)
2d2d72
+                self.assertIsInstance(v, list)
2d2d72
+                for e in v:
2d2d72
+                    self.assertIsInstance(e, dict)
2d2d72
+        else:
2d2d72
+            # No mailcap files on system. getcaps() should return empty dict.
2d2d72
+            self.assertEqual({}, caps)
2d2d72
+
2d2d72
+
2d2d72
+class FindmatchTest(unittest.TestCase):
2d2d72
+
2d2d72
+    def test_findmatch(self):
2d2d72
+
2d2d72
+        # default findmatch arguments
2d2d72
+        c = MAILCAPDICT
2d2d72
+        fname = "foo.txt"
2d2d72
+        plist = ["access-type=default", "name=john", "site=python.org",
2d2d72
+                 "directory=/tmp", "mode=foo", "server=bar"]
2d2d72
+        audio_basic_entry = {
2d2d72
+            'edit': 'audiocompose %s',
2d2d72
+            'compose': 'audiocompose %s',
2d2d72
+            'description': '"An audio fragment"',
2d2d72
+            'view': 'showaudio %s',
2d2d72
+        }
2d2d72
+        audio_entry = {"view": "/usr/local/bin/showaudio %t", }
2d2d72
+        video_entry = {'view': 'animate %s', }
2d2d72
+        mpeg_entry = {'view': 'mpeg_play %s', }
2d2d72
+        message_entry = {
2d2d72
+            'composetyped': 'extcompose %s',
2d2d72
+            'description': '"A reference to data stored in an external location"', 'needsterminal': '',
2d2d72
+            'view': 'showexternal %s %{access-type} %{name} %{site}     %{directory} %{mode} %{server}',
2d2d72
+        }
2d2d72
+
2d2d72
+        # test case: (findmatch args, findmatch keyword args, expected output)
2d2d72
+        #   positional args: caps, MIMEtype
2d2d72
+        #   keyword args: key="view", filename="/dev/null", plist=[]
2d2d72
+        #   output: (command line, mailcap entry)
2d2d72
+        cases = [
2d2d72
+            ([{}, "video/mpeg"], {}, (None, None)),
2d2d72
+            ([c, "foo/bar"], {}, (None, None)),
2d2d72
+
2d2d72
+            # In Python 2, 'video/mpeg' is tried before 'video/*'
2d2d72
+            # (unfixed bug: https://github.com/python/cpython/issues/59182 )
2d2d72
+            #([c, "video/mpeg"], {}, ('animate /dev/null', video_entry)),
2d2d72
+            ([c, "video/mpeg"], {}, ('mpeg_play /dev/null', mpeg_entry)),
2d2d72
+
2d2d72
+            ([c, "audio/basic", "edit"], {}, ("audiocompose /dev/null", audio_basic_entry)),
2d2d72
+            ([c, "audio/basic", "compose"], {}, ("audiocompose /dev/null", audio_basic_entry)),
2d2d72
+            ([c, "audio/basic", "description"], {}, ('"An audio fragment"', audio_basic_entry)),
2d2d72
+            ([c, "audio/basic", "foobar"], {}, (None, None)),
2d2d72
+            ([c, "video/*"], {"filename": fname}, ("animate %s" % fname, video_entry)),
2d2d72
+            ([c, "audio/basic", "compose"],
2d2d72
+             {"filename": fname},
2d2d72
+             ("audiocompose %s" % fname, audio_basic_entry)),
2d2d72
+            ([c, "audio/basic"],
2d2d72
+             {"key": "description", "filename": fname},
2d2d72
+             ('"An audio fragment"', audio_basic_entry)),
2d2d72
+            ([c, "audio/*"],
2d2d72
+             {"filename": fname},
2d2d72
+             (None, None)),
2d2d72
+            ([c, "audio/wav"],
2d2d72
+             {"filename": fname},
2d2d72
+             ("/usr/local/bin/showaudio audio/wav", audio_entry)),
2d2d72
+            ([c, "message/external-body"],
2d2d72
+             {"plist": plist},
2d2d72
+             ("showexternal /dev/null default john python.org     /tmp foo bar", message_entry))
2d2d72
+        ]
2d2d72
+        self._run_cases(cases)
2d2d72
+
2d2d72
+    @unittest.skipUnless(os.name == "posix", "Requires 'test' command on system")
2d2d72
+    @unittest.skipIf(sys.platform == "vxworks", "'test' command is not supported on VxWorks")
2d2d72
+    def test_test(self):
2d2d72
+        # findmatch() will automatically check any "test" conditions and skip
2d2d72
+        # the entry if the check fails.
2d2d72
+        caps = {"test/pass": [{"test": "test 1 -eq 1"}],
2d2d72
+                "test/fail": [{"test": "test 1 -eq 0"}]}
2d2d72
+        # test case: (findmatch args, findmatch keyword args, expected output)
2d2d72
+        #   positional args: caps, MIMEtype, key ("test")
2d2d72
+        #   keyword args: N/A
2d2d72
+        #   output: (command line, mailcap entry)
2d2d72
+        cases = [
2d2d72
+            # findmatch will return the mailcap entry for test/pass because it evaluates to true
2d2d72
+            ([caps, "test/pass", "test"], {}, ("test 1 -eq 1", {"test": "test 1 -eq 1"})),
2d2d72
+            # findmatch will return None because test/fail evaluates to false
2d2d72
+            ([caps, "test/fail", "test"], {}, (None, None))
2d2d72
+        ]
2d2d72
+        self._run_cases(cases)
2d2d72
+
2d2d72
+    def _run_cases(self, cases):
2d2d72
+        for c in cases:
2d2d72
+            self.assertEqual(mailcap.findmatch(*c[0], **c[1]), c[2])
2d2d72
+
2d2d72
+
2d2d72
+def test_main():
2d2d72
+    test.support.run_unittest(HelperFunctionTest, GetcapsTest, FindmatchTest)
2d2d72
diff --git a/Misc/NEWS.d/next/Security/2022-04-27-18-25-30.gh-issue-68966.gjS8zs.rst b/Misc/NEWS.d/next/Security/2022-04-27-18-25-30.gh-issue-68966.gjS8zs.rst
2d2d72
new file mode 100644
2d2d72
index 00000000000..da81a1f6993
2d2d72
--- /dev/null
2d2d72
+++ b/Misc/NEWS.d/next/Security/2022-04-27-18-25-30.gh-issue-68966.gjS8zs.rst
2d2d72
@@ -0,0 +1,4 @@
2d2d72
+The deprecated mailcap module now refuses to inject unsafe text (filenames,
2d2d72
+MIME types, parameters) into shell commands. Instead of using such text, it
2d2d72
+will warn and act as if a match was not found (or for test commands, as if
2d2d72
+the test failed).