Skip to content

Commit 085ad6a

Browse files
zoobamiss-islington
authored andcommitted
pythongh-114539: Clarify implicit launching of shells by subprocess (pythonGH-117996)
(cherry picked from commit a4b44d3) Co-authored-by: Steve Dower <[email protected]>
1 parent 3bc0d2b commit 085ad6a

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
@@ -756,8 +756,8 @@ Exceptions defined in this module all inherit from :exc:`SubprocessError`.
756756
Security Considerations
757757
-----------------------
758758

759-
Unlike some other popen functions, this implementation will never
760-
implicitly call a system shell. This means that all characters,
759+
Unlike some other popen functions, this library will not
760+
implicitly choose to call a system shell. This means that all characters,
761761
including shell metacharacters, can safely be passed to child processes.
762762
If the shell is invoked explicitly, via ``shell=True``, it is the application's
763763
responsibility to ensure that all whitespace and metacharacters are
@@ -766,6 +766,14 @@ quoted appropriately to avoid
766766
vulnerabilities. On :ref:`some platforms <shlex-quote-warning>`, it is possible
767767
to use :func:`shlex.quote` for this escaping.
768768

769+
On Windows, batch files (:file:`*.bat` or :file:`*.cmd`) may be launched by the
770+
operating system in a system shell regardless of the arguments passed to this
771+
library. This could result in arguments being parsed according to shell rules,
772+
but without any escaping added by Python. If you are intentionally launching a
773+
batch file with arguments from untrusted sources, consider passing
774+
``shell=True`` to allow Python to escape special characters. See :gh:`114539`
775+
for additional discussion.
776+
769777

770778
Popen Objects
771779
-------------

0 commit comments

Comments
 (0)