Skip to content

gh-68966: Document mailcap shell injection vulnerability #92024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Doc/library/mailcap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ The mailcap format is documented in :rfc:`1524`, "A User Agent Configuration
Mechanism For Multimedia Mail Format Information", but is not an internet
standard. However, mailcap files are supported on most Unix systems.

.. _mailcap-shell-injection:

.. warning::

The Python implementation is vulnerable to shell command injection. By
design, the mailcap format uses shell commands. The caller is responsible to
validate and sanitize input arguments.

For the filename, the caller can create a temporary filename, using
:func:`tempfile.NamedTemporaryFile` or :func:`tempfile.mkstemp` for example,
to get a safe filename.


.. function:: findmatch(caps, MIMEtype, key='view', filename='/dev/null', plist=[])

Expand Down
1 change: 1 addition & 0 deletions Doc/library/security_warnings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The following modules have specific security considerations:
basic security checks
* :mod:`logging`: :ref:`Logging configuration uses eval()
<logging-eval-security>`
* :mod:`mailcap`: :ref:`Shell command injection <mailcap-shell-injection>`
* :mod:`multiprocessing`: :ref:`Connection.recv() uses pickle
<multiprocessing-recv-pickle-security>`
* :mod:`pickle`: :ref:`Restricting globals in pickle <pickle-restrict>`
Expand Down