]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] gh-114539: Clarify implicit launching of shells by subprocess (GH-117996)...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 7 May 2024 08:47:46 +0000 (10:47 +0200)
committerGitHub <noreply@github.com>
Tue, 7 May 2024 08:47:46 +0000 (10:47 +0200)
(cherry picked from commit a4b44d39cd6941cc03590fee7538776728bdfd0a)

Co-authored-by: Steve Dower <steve.dower@python.org>
Doc/library/subprocess.rst

index fc66663546b98217eaa5b530e5e461cb29634109..7eb9f3042405ff2575dc54151c2f2026121f9688 100644 (file)
@@ -741,8 +741,8 @@ Exceptions defined in this module all inherit from :exc:`SubprocessError`.
 Security Considerations
 -----------------------
 
-Unlike some other popen functions, this implementation will never
-implicitly call a system shell.  This means that all characters,
+Unlike some other popen functions, this library will not
+implicitly choose to call a system shell.  This means that all characters,
 including shell metacharacters, can safely be passed to child processes.
 If the shell is invoked explicitly, via ``shell=True``, it is the application's
 responsibility to ensure that all whitespace and metacharacters are
@@ -751,6 +751,14 @@ quoted appropriately to avoid
 vulnerabilities. On :ref:`some platforms <shlex-quote-warning>`, it is possible
 to use :func:`shlex.quote` for this escaping.
 
+On Windows, batch files (:file:`*.bat` or :file:`*.cmd`) may be launched by the
+operating system in a system shell regardless of the arguments passed to this
+library. This could result in arguments being parsed according to shell rules,
+but without any escaping added by Python. If you are intentionally launching a
+batch file with arguments from untrusted sources, consider passing
+``shell=True`` to allow Python to escape special characters. See :gh:`114539`
+for additional discussion.
+
 
 Popen Objects
 -------------