aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-07 10:48:26 +0200
committerGitHub <noreply@github.com>2024-05-07 10:48:26 +0200
commit14ac620e280aba83ce73b742ca36ac5e614b9a0a (patch)
tree06795128b073f78d32496810e9f4e93041a05f30
parentf5bd65ed37bbccfa113438cf9e34feae6816ecb1 (diff)
downloadcpython3-14ac620e280aba83ce73b742ca36ac5e614b9a0a.tar.gz
[3.8] gh-114539: Clarify implicit launching of shells by subprocess (GH-117996) (GH-118006)
(cherry picked from commit a4b44d39cd6941cc03590fee7538776728bdfd0a) Co-authored-by: Steve Dower <steve.dower@python.org>
-rw-r--r--Doc/library/subprocess.rst12
1 files changed, 10 insertions, 2 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 8eea5a474e..2acbbbb4c0 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -666,8 +666,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
@@ -679,6 +679,14 @@ When using ``shell=True``, the :func:`shlex.quote` function can be
used to properly escape whitespace and shell metacharacters in strings
that are going to be used to construct shell commands.
+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
-------------