Skip to content

Commit 14ac620

Browse files
[3.8] gh-114539: Clarify implicit launching of shells by subprocess (GH-117996) (GH-118006)
(cherry picked from commit a4b44d3) Co-authored-by: Steve Dower <steve.dower@python.org>
1 parent f5bd65e commit 14ac620

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Doc/library/subprocess.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,8 @@ Exceptions defined in this module all inherit from :exc:`SubprocessError`.
666666
Security Considerations
667667
-----------------------
668668

669-
Unlike some other popen functions, this implementation will never
670-
implicitly call a system shell. This means that all characters,
669+
Unlike some other popen functions, this library will not
670+
implicitly choose to call a system shell. This means that all characters,
671671
including shell metacharacters, can safely be passed to child processes.
672672
If the shell is invoked explicitly, via ``shell=True``, it is the application's
673673
responsibility to ensure that all whitespace and metacharacters are
@@ -679,6 +679,14 @@ When using ``shell=True``, the :func:`shlex.quote` function can be
679679
used to properly escape whitespace and shell metacharacters in strings
680680
that are going to be used to construct shell commands.
681681

682+
On Windows, batch files (:file:`*.bat` or :file:`*.cmd`) may be launched by the
683+
operating system in a system shell regardless of the arguments passed to this
684+
library. This could result in arguments being parsed according to shell rules,
685+
but without any escaping added by Python. If you are intentionally launching a
686+
batch file with arguments from untrusted sources, consider passing
687+
``shell=True`` to allow Python to escape special characters. See :gh:`114539`
688+
for additional discussion.
689+
682690

683691
Popen Objects
684692
-------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy