Skip to content

bpo-39498 Start linking the security warnings in the stdlib modules #18272

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

Merged
merged 5 commits into from
Aug 9, 2021
Merged
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
2 changes: 2 additions & 0 deletions Doc/library/hashlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ library that Python uses on your platform. On most platforms the
.. versionadded:: 3.6
:func:`blake2b` and :func:`blake2s` were added.

.. _hashlib-usedforsecurity:

.. versionchanged:: 3.9
All hashlib constructors take a keyword-only argument *usedforsecurity*
with default value ``True``. A false value allows the use of insecure and
Expand Down
1 change: 1 addition & 0 deletions Doc/library/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ the `Python Package Index <https://pypi.org>`_.
unix.rst
superseded.rst
undoc.rst
security_warnings.rst
2 changes: 2 additions & 0 deletions Doc/library/logging.config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ in :mod:`logging` itself) and defining handlers which are declared either in
send it to the socket as a sequence of bytes preceded by a four-byte length
string packed in binary using ``struct.pack('>L', n)``.

.. _logging-eval-security:

.. note::

Because portions of the configuration are passed through
Expand Down
1 change: 1 addition & 0 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ For example:
>>> arr2
array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])

.. _multiprocessing-recv-pickle-security:

.. warning::

Expand Down
32 changes: 32 additions & 0 deletions Doc/library/security_warnings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. _security-warnings:

.. index:: single: security considerations

Security Considerations
=======================

The following modules have specific security considerations:

* :mod:`cgi`: :ref:`CGI security considerations <cgi-security>`
* :mod:`hashlib`: :ref:`all constructors take a "usedforsecurity" keyword-only
argument disabling known insecure and blocked algorithms
<hashlib-usedforsecurity>`
* :mod:`http.server` is not suitable for production use, only implementing
basic security checks
* :mod:`logging`: :ref:`Logging configuration uses eval()
<logging-eval-security>`
* :mod:`multiprocessing`: :ref:`Connection.recv() uses pickle
<multiprocessing-recv-pickle-security>`
* :mod:`pickle`: :ref:`Restricting globals in pickle <pickle-restrict>`
* :mod:`random` shouldn't be used for security purposes, use :mod:`secrets`
instead
* :mod:`shelve`: :ref:`shelve is based on pickle and thus unsuitable for
dealing with untrusted sources <shelve-security>`
* :mod:`ssl`: :ref:`SSL/TLS security considerations <ssl-security>`
* :mod:`subprocess`: :ref:`Subprocess security considerations
<subprocess-security>`
* :mod:`tempfile`: :ref:`mktemp is deprecated due to vulnerability to race
conditions <tempfile-mktemp-deprecated>`
* :mod:`xml`: :ref:`XML vulnerabilities <xml-vulnerabilities>`
* :mod:`zipfile`: :ref:`maliciously prepared .zip files can cause disk volume
exhaustion <zipfile-resources-limitations>`
2 changes: 2 additions & 0 deletions Doc/library/shelve.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ lots of shared sub-objects. The keys are ordinary strings.
with shelve.open('spam') as db:
db['eggs'] = 'eggs'

.. _shelve-security:

.. warning::

Because the :mod:`shelve` module is backed by :mod:`pickle`, it is insecure
Expand Down
1 change: 1 addition & 0 deletions Doc/library/subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ Exceptions defined in this module all inherit from :exc:`SubprocessError`.
.. versionadded:: 3.3
The :exc:`SubprocessError` base class was added.

.. _subprocess-security:

Security Considerations
-----------------------
Expand Down
1 change: 1 addition & 0 deletions Doc/library/tempfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ Here are some examples of typical usage of the :mod:`tempfile` module::
>>>
# directory and contents have been removed

.. _tempfile-mktemp-deprecated:

Deprecated functions and variables
----------------------------------
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/zipfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ Exceeding limitations on different file systems can cause decompression failed.
Such as allowable characters in the directory entries, length of the file name,
length of the pathname, size of a single file, and number of files, etc.

.. _zipfile-resources-limitations:

Resources limitations
~~~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a "Security Considerations" index which links to standard library modules that have explicitly documented security considerations.